Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Silence some optional Xcode 9 warnings #348

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion support-lib/objc/DJIError.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ namespace djinni {
::djinni::throwUnimplemented(__PRETTY_FUNCTION__, msg);

#define DJINNI_TRANSLATE_EXCEPTIONS() \
catch (const std::exception & e) { \
catch (__unused const std::exception & e) { \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to simply delete the name? It is truly unused, and removing the name is a more standard way to do it in C++.

::djinni::throwNSExceptionFromCurrent(__PRETTY_FUNCTION__); \
}
6 changes: 3 additions & 3 deletions support-lib/objc/DJIMarshal+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct Bool {

struct Boxed {
using ObjcType = NSNumber*;
static CppType toCpp(ObjcType x) noexcept { assert(x); return Bool::toCpp([x boolValue]); }
static CppType toCpp(ObjcType x) noexcept { assert(x != nil); return Bool::toCpp([x boolValue]); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Stylistically I generally do prefer to let pointers be treated as bools directly, but in this context I'm fine with changing the code to be more generally usable by people who don't like that style and turn on warnings against it.

static ObjcType fromCpp(CppType x) noexcept { return [NSNumber numberWithBool:Bool::fromCpp(x)]; }
};
};
Expand All @@ -44,7 +44,7 @@ struct Primitive {

struct Boxed {
using ObjcType = NSNumber*;
static CppType toCpp(ObjcType x) noexcept { assert(x); return static_cast<CppType>(Self::unbox(x)); }
static CppType toCpp(ObjcType x) noexcept { assert(x != nil); return static_cast<CppType>(Self::unbox(x)); }
static ObjcType fromCpp(CppType x) noexcept { return Self::box(x); }
};
};
Expand Down Expand Up @@ -233,7 +233,7 @@ class Optional {
using Boxed = Optional;

static CppType toCpp(ObjcType obj) {
if (obj) {
if (obj != nil) {
return T::Boxed::toCpp(obj);
} else {
return CppType();
Expand Down