mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Merge branch 'main' into 12.0-development
This commit is contained in:
+16
-2
@@ -36,6 +36,11 @@ set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
|
||||
if(APPLE)
|
||||
message(WARNING "CMake is not an officially supported build system for love on Apple platforms.")
|
||||
message(WARNING "Use the prebuilt .app or the xcode project in platform/xcode/ instead.")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(LOVE_CONSOLE_EXE_NAME lovec)
|
||||
endif()
|
||||
@@ -48,11 +53,15 @@ else()
|
||||
set(LOVE_TARGET_PLATFORM x86)
|
||||
endif()
|
||||
|
||||
option(LOVE_JIT "Use LuaJIT" TRUE)
|
||||
if(APPLE)
|
||||
option(LOVE_JIT "Use LuaJIT" FALSE)
|
||||
else()
|
||||
option(LOVE_JIT "Use LuaJIT" TRUE)
|
||||
endif()
|
||||
|
||||
if(LOVE_JIT)
|
||||
if(APPLE)
|
||||
message(FATAL_ERROR "JIT not supported yet on Mac. Please use -DLOVE_JIT=0.")
|
||||
message(WARNING "JIT not supported yet on Mac.")
|
||||
endif()
|
||||
message(STATUS "LuaJIT: Enabled")
|
||||
else()
|
||||
@@ -289,6 +298,9 @@ if (APPLE)
|
||||
set(LOVE_SRC_COMMON ${LOVE_SRC_COMMON}
|
||||
src/common/macosx.mm
|
||||
)
|
||||
set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} objc)
|
||||
set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} "-framework CoreFoundation")
|
||||
set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} "-framework AppKit")
|
||||
endif()
|
||||
|
||||
source_group("common" FILES ${LOVE_SRC_COMMON})
|
||||
@@ -1624,6 +1636,7 @@ if(APPLE)
|
||||
set(LOVE_SRC_3P_PHYSFS ${LOVE_SRC_3P_PHYSFS}
|
||||
src/libraries/physfs/physfs_platform_apple.m
|
||||
)
|
||||
set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} "-framework IOKit")
|
||||
endif()
|
||||
|
||||
add_library(love_3p_physfs ${LOVE_SRC_3P_PHYSFS})
|
||||
@@ -1744,6 +1757,7 @@ set(LOVE_LIB_SRC
|
||||
)
|
||||
|
||||
include_directories(
|
||||
BEFORE
|
||||
src
|
||||
src/libraries
|
||||
src/libraries/box2D
|
||||
|
||||
@@ -100,11 +100,6 @@ Audio::Audio()
|
||||
, poolThread(nullptr)
|
||||
, distanceModel(DISTANCE_INVERSE_CLAMPED)
|
||||
{
|
||||
#if defined(LOVE_LINUX)
|
||||
// Temporarly block signals, as the thread inherits this mask
|
||||
love::thread::disableSignals();
|
||||
#endif
|
||||
|
||||
// Before opening new device, check if recording
|
||||
// is requested.
|
||||
if (getRequestRecordingPermission())
|
||||
@@ -114,29 +109,32 @@ Audio::Audio()
|
||||
requestRecordingPermission();
|
||||
}
|
||||
|
||||
// Passing null for default device.
|
||||
device = alcOpenDevice(nullptr);
|
||||
{
|
||||
#if defined(LOVE_LINUX)
|
||||
// Temporarly block signals, as the thread inherits this mask
|
||||
love::thread::ScopedDisableSignals disableSignals;
|
||||
#endif
|
||||
|
||||
if (device == nullptr)
|
||||
throw love::Exception("Could not open device.");
|
||||
// Passing null for default device.
|
||||
device = alcOpenDevice(nullptr);
|
||||
|
||||
if (device == nullptr)
|
||||
throw love::Exception("Could not open device.");
|
||||
|
||||
#ifdef ALC_EXT_EFX
|
||||
ALint attribs[4] = { ALC_MAX_AUXILIARY_SENDS, MAX_SOURCE_EFFECTS, 0, 0 };
|
||||
ALint attribs[4] = { ALC_MAX_AUXILIARY_SENDS, MAX_SOURCE_EFFECTS, 0, 0 };
|
||||
#else
|
||||
ALint *attribs = nullptr;
|
||||
ALint *attribs = nullptr;
|
||||
#endif
|
||||
|
||||
context = alcCreateContext(device, attribs);
|
||||
context = alcCreateContext(device, attribs);
|
||||
|
||||
if (context == nullptr)
|
||||
throw love::Exception("Could not create context.");
|
||||
if (context == nullptr)
|
||||
throw love::Exception("Could not create context.");
|
||||
|
||||
if (!alcMakeContextCurrent(context) || alcGetError(device) != ALC_NO_ERROR)
|
||||
throw love::Exception("Could not make context current.");
|
||||
|
||||
#if defined(LOVE_LINUX)
|
||||
love::thread::reenableSignals();
|
||||
#endif
|
||||
if (!alcMakeContextCurrent(context) || alcGetError(device) != ALC_NO_ERROR)
|
||||
throw love::Exception("Could not make context current.");
|
||||
}
|
||||
|
||||
#ifdef ALC_EXT_EFX
|
||||
initializeEFX();
|
||||
|
||||
@@ -164,7 +164,7 @@ bool System::openURL(const std::string &url) const
|
||||
|
||||
#endif
|
||||
|
||||
return (int) result > 32;
|
||||
return (ptrdiff_t) result > 32;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ love::Type LuaThread::type("Thread", &Threadable::type);
|
||||
LuaThread::LuaThread(const std::string &name, love::Data *code)
|
||||
: code(code)
|
||||
, name(name)
|
||||
, haserror(false)
|
||||
{
|
||||
threadName = name;
|
||||
}
|
||||
@@ -48,6 +49,7 @@ LuaThread::~LuaThread()
|
||||
void LuaThread::threadFunction()
|
||||
{
|
||||
error.clear();
|
||||
haserror = false;
|
||||
|
||||
lua_State *L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
@@ -71,7 +73,10 @@ void LuaThread::threadFunction()
|
||||
int tracebackidx = lua_gettop(L);
|
||||
|
||||
if (luaL_loadbuffer(L, (const char *) code->getData(), code->getSize(), name.c_str()) != 0)
|
||||
{
|
||||
error = luax_tostring(L, -1);
|
||||
haserror = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int pushedargs = (int) args.size();
|
||||
@@ -82,18 +87,27 @@ void LuaThread::threadFunction()
|
||||
args.clear();
|
||||
|
||||
if (lua_pcall(L, pushedargs, 0, tracebackidx) != 0)
|
||||
{
|
||||
error = luax_tostring(L, -1);
|
||||
haserror = true;
|
||||
}
|
||||
}
|
||||
|
||||
lua_close(L);
|
||||
|
||||
if (!error.empty())
|
||||
if (haserror)
|
||||
onError();
|
||||
}
|
||||
|
||||
bool LuaThread::start(const std::vector<Variant> &args)
|
||||
{
|
||||
if (isRunning())
|
||||
return false;
|
||||
|
||||
this->args = args;
|
||||
error.clear();
|
||||
haserror = false;
|
||||
|
||||
return Threadable::start();
|
||||
}
|
||||
|
||||
@@ -104,9 +118,6 @@ const std::string &LuaThread::getError() const
|
||||
|
||||
void LuaThread::onError()
|
||||
{
|
||||
if (error.empty())
|
||||
return;
|
||||
|
||||
auto eventmodule = Module::getInstance<event::Event>(Module::M_EVENT);
|
||||
if (!eventmodule)
|
||||
return;
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
virtual ~LuaThread();
|
||||
void threadFunction();
|
||||
const std::string &getError() const;
|
||||
bool hasError() const { return haserror; }
|
||||
|
||||
bool start(const std::vector<Variant> &args);
|
||||
|
||||
@@ -56,6 +57,7 @@ private:
|
||||
StrongRef<love::Data> code;
|
||||
std::string name;
|
||||
std::string error;
|
||||
bool haserror;
|
||||
|
||||
std::vector<Variant> args;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ bool Thread::start()
|
||||
{
|
||||
#if defined(LOVE_LINUX)
|
||||
// Temporarly block signals, as the thread inherits this mask
|
||||
love::thread::disableSignals();
|
||||
love::thread::ScopedDisableSignals disableSignals;
|
||||
#endif
|
||||
|
||||
Lock l(mutex);
|
||||
@@ -55,9 +55,6 @@ bool Thread::start()
|
||||
thread = SDL_CreateThread(thread_runner, t->getThreadName(), this);
|
||||
running = (thread != nullptr);
|
||||
|
||||
#if defined(LOVE_LINUX)
|
||||
love::thread::reenableSignals();
|
||||
#endif
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,12 @@ Thread *newThread(Threadable *t);
|
||||
#if defined(LOVE_LINUX)
|
||||
void disableSignals();
|
||||
void reenableSignals();
|
||||
|
||||
struct ScopedDisableSignals
|
||||
{
|
||||
ScopedDisableSignals() { disableSignals(); }
|
||||
~ScopedDisableSignals() { reenableSignals(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
} // thread
|
||||
|
||||
@@ -63,11 +63,10 @@ int w_Thread_wait(lua_State *L)
|
||||
int w_Thread_getError(lua_State *L)
|
||||
{
|
||||
LuaThread *t = luax_checkthread(L, 1);
|
||||
std::string err = t->getError();
|
||||
if (err.empty())
|
||||
lua_pushnil(L);
|
||||
if (t->hasError())
|
||||
luax_pushstring(L, t->getError());
|
||||
else
|
||||
luax_pushstring(L, err);
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user