# HG changeset patch # User Paper # Date 1701713994 18000 # Node ID c413e475f496dc9e3a8791a4d613a791924230b1 # Parent d26cd2c00270308b09b25d6615144976c7855d82 dep/animia: various stylistic changes diff -r d26cd2c00270 -r c413e475f496 dep/animia/CMakeLists.txt --- a/dep/animia/CMakeLists.txt Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/CMakeLists.txt Mon Dec 04 13:19:54 2023 -0500 @@ -30,6 +30,12 @@ # check anyway. if (HAVE_COREFOUNDATION) list(APPEND DEFINES HAVE_COREFOUNDATION) + + find_library(FOUNDATION_LIBRARY Foundation) + list(APPEND LIBRARIES ${FOUNDATION_LIBRARY}) + else() + message(STATUS "You don't have Core Foundation. How? What kind of voodoo magic did you do to cause this?") + message(WARNING "LaunchServices support will not be compiled.") endif() check_language(OBJCXX) @@ -38,10 +44,11 @@ list(APPEND SRC_FILES src/win/quartz.mm ) - find_library(FOUNDATION_LIBRARY Foundation) + + # we likely already have Foundation at this point. find_library(COREGRAPHICS_LIBRARY CoreGraphics) find_library(APPKIT_LIBRARY AppKit) - list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY}) + list(APPEND LIBRARIES ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY}) else() # NOT CMAKE_OBJCXX_COMPILER message(WARNING "An Objective-C++ compiler couldn't be found! Window enumeration support will not be compiled.") endif() # CMAKE_OBJCXX_COMPILER diff -r d26cd2c00270 -r c413e475f496 dep/animia/src/fd/proc.cc --- a/dep/animia/src/fd/proc.cc Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/src/fd/proc.cc Mon Dec 04 13:19:54 2023 -0500 @@ -82,6 +82,8 @@ return false; // we got a bad result, i think } + out.resize(out.find('\0')); + return true; } diff -r d26cd2c00270 -r c413e475f496 dep/animia/src/fd/win32.cc --- a/dep/animia/src/fd/win32.cc Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/src/fd/win32.cc Mon Dec 04 13:19:54 2023 -0500 @@ -32,8 +32,6 @@ * 32-bit PIDs, unlike SystemHandleInformation */ constexpr SYSTEM_INFORMATION_CLASS SystemExtendedHandleInformation = static_cast(0x40); - -/* more constants not in winternl.h */ constexpr NTSTATUS STATUS_INFO_LENGTH_MISMATCH = 0xC0000004UL; /* this is filled in at runtime because it's not guaranteed to be (and isn't) diff -r d26cd2c00270 -r c413e475f496 dep/animia/src/util/osx.cc --- a/dep/animia/src/util/osx.cc Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/src/util/osx.cc Mon Dec 04 13:19:54 2023 -0500 @@ -84,11 +84,13 @@ str.reset(rstr); } - result.reserve(CFStringGetMaximumSizeForEncoding(CFStringGetLength(str.get()), kCFStringEncodingUTF8) + 1); + result.resize(CFStringGetMaximumSizeForEncoding(CFStringGetLength(str.get()), kCFStringEncodingUTF8) + 1); if (!CFStringGetCString(str.get(), &result.front(), result.length(), result.length())) return false; + result.resize(result.find('\0')); + return true; } #endif // HAVE_COREFOUNDATION @@ -98,7 +100,11 @@ const int mib[3] = {CTL_KERN, KERN_PROCARGS2, static_cast(pid)}; const size_t mib_size = sizeof(mib)/sizeof(*mib); - /* Get the initial size of the array */ + /* Get the initial size of the array + * + * NOTE: it IS possible for this value to change inbetween calls to sysctl(). + * Unfortunately, I couldn't care less about handling this. :) + */ size_t size; { int ret = sysctl((int*)mib, mib_size, nullptr, &size, nullptr, 0); diff -r d26cd2c00270 -r c413e475f496 dep/animia/src/win/quartz.mm --- a/dep/animia/src/win/quartz.mm Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/src/win/quartz.mm Mon Dec 04 13:19:54 2023 -0500 @@ -1,3 +1,11 @@ +/* We actually DON'T need Objective-C for most of this file. + * GetWindowTitle() is the only function that really needs it. + * (and even then, we can use the C bindings for it...) + * + * However, being able to use the Foundation classes makes things + * so, so, so much easier, and so I've decided to make this file + * in Objective-C++. +*/ #include "animia/win/quartz.h" #include "animia.h" @@ -24,6 +32,7 @@ return true; } +/* This is really the only a*/ static bool GetWindowTitle(unsigned int wid, std::string& result) { NSWindow* window = [NSApp windowWithWindowNumber: wid]; if (!window)