Skip to content

Commit

Permalink
fix macos build
Browse files Browse the repository at this point in the history
  • Loading branch information
qimiko committed Nov 9, 2024
1 parent 13b7cfc commit 5eda753
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 6 additions & 1 deletion loader/src/platform/mac/LoaderImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ CFDataRef msgPortCallback(CFMessagePortRef port, SInt32 messageID, CFDataRef dat

std::string cdata(reinterpret_cast<char const*>(CFDataGetBytePtr(data)), CFDataGetLength(data));

std::string reply = geode::ipc::processRaw(port, cdata).dump();
auto res = geode::ipc::processRaw(port, cdata).dump();
if (!res) {
log::warn("Failed to process IPC message: {}", res.unwrapErr());
}
std::string reply = res.unwrapOr("");

return CFDataCreate(NULL, (UInt8 const*)reply.data(), reply.size());
}

Expand Down
12 changes: 6 additions & 6 deletions loader/src/platform/mac/util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ @implementation FileDialog

@interface FileDialog : NSObject
+(Result<std::vector<std::filesystem::path>>) filePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult;
+(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult onCompletion:(void(^)(FileResult))onCompletion;
+(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult onCompletion:(void(^)(FileResult&&))onCompletion;
@end

@implementation FileDialog
Expand Down Expand Up @@ -152,10 +152,10 @@ @implementation FileDialog
}
}

+(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult onCompletion:(void(^)(FileResult))onCompletion {
+(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult onCompletion:(void(^)(FileResult&&))onCompletion {
dispatch_async(dispatch_get_main_queue(), ^{
auto result = [self filePickerWithMode:mode options:options multiple:mult];
onCompletion(result);
onCompletion(std::move(result));
});
}

Expand All @@ -164,7 +164,7 @@ +(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickO
GEODE_DLL Task<Result<std::filesystem::path>> file::pick(file::PickMode mode, file::FilePickOptions const& options) {
using RetTask = Task<Result<std::filesystem::path>>;
return RetTask::runWithCallback([mode, options](auto resultCallback, auto progress, auto cancelled) {
[FileDialog dispatchFilePickerWithMode:mode options:options multiple:false onCompletion: ^(FileResult result) {
[FileDialog dispatchFilePickerWithMode:mode options:options multiple:false onCompletion: ^(FileResult&& result) {
if (cancelled()) {
resultCallback(RetTask::Cancel());
} else {
Expand All @@ -182,11 +182,11 @@ +(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickO
GEODE_DLL Task<Result<std::vector<std::filesystem::path>>> file::pickMany(file::FilePickOptions const& options) {
using RetTask = Task<Result<std::vector<std::filesystem::path>>>;
return RetTask::runWithCallback([options](auto resultCallback, auto progress, auto cancelled) {
[FileDialog dispatchFilePickerWithMode: file::PickMode::OpenFile options:options multiple:true onCompletion: ^(FileResult result) {
[FileDialog dispatchFilePickerWithMode: file::PickMode::OpenFile options:options multiple:true onCompletion: ^(FileResult&& result) {
if (cancelled()) {
resultCallback(RetTask::Cancel());
} else {
resultCallback(result);
resultCallback(std::move(result));
}
}];
});
Expand Down

0 comments on commit 5eda753

Please sign in to comment.