Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5001096e authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder_ndk: core object type comparison

Comparison operators for core types which are missing these, in order to
support comparison of arbitrary NDK backend types.

Bug: 175018841
Test: atest CtsNdkBinderTestCases
Change-Id: I3c112d0883c4d51fd5376709f3db4d72b6883697
parent e2ccad36
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -114,6 +114,13 @@ class SpAIBinder {
     */
    AIBinder** getR() { return &mBinder; }

    bool operator!=(const SpAIBinder& rhs) const { return get() != rhs.get(); }
    bool operator<(const SpAIBinder& rhs) const { return get() < rhs.get(); }
    bool operator<=(const SpAIBinder& rhs) const { return get() <= rhs.get(); }
    bool operator==(const SpAIBinder& rhs) const { return get() == rhs.get(); }
    bool operator>(const SpAIBinder& rhs) const { return get() > rhs.get(); }
    bool operator>=(const SpAIBinder& rhs) const { return get() >= rhs.get(); }

   private:
    AIBinder* mBinder = nullptr;
};
@@ -200,6 +207,13 @@ class ScopedAParcel : public impl::ScopedAResource<AParcel*, void, AParcel_delet
    ~ScopedAParcel() {}
    ScopedAParcel(ScopedAParcel&&) = default;
    ScopedAParcel& operator=(ScopedAParcel&&) = default;

    bool operator!=(const ScopedAParcel& rhs) const { return get() != rhs.get(); }
    bool operator<(const ScopedAParcel& rhs) const { return get() < rhs.get(); }
    bool operator<=(const ScopedAParcel& rhs) const { return get() <= rhs.get(); }
    bool operator==(const ScopedAParcel& rhs) const { return get() == rhs.get(); }
    bool operator>(const ScopedAParcel& rhs) const { return get() > rhs.get(); }
    bool operator>=(const ScopedAParcel& rhs) const { return get() >= rhs.get(); }
};

/**
@@ -323,6 +337,13 @@ class ScopedFileDescriptor : public impl::ScopedAResource<int, int, close, -1> {
    ~ScopedFileDescriptor() {}
    ScopedFileDescriptor(ScopedFileDescriptor&&) = default;
    ScopedFileDescriptor& operator=(ScopedFileDescriptor&&) = default;

    bool operator!=(const ScopedFileDescriptor& rhs) const { return get() != rhs.get(); }
    bool operator<(const ScopedFileDescriptor& rhs) const { return get() < rhs.get(); }
    bool operator<=(const ScopedFileDescriptor& rhs) const { return get() <= rhs.get(); }
    bool operator==(const ScopedFileDescriptor& rhs) const { return get() == rhs.get(); }
    bool operator>(const ScopedFileDescriptor& rhs) const { return get() > rhs.get(); }
    bool operator>=(const ScopedFileDescriptor& rhs) const { return get() >= rhs.get(); }
};

}  // namespace ndk
+19 −0
Original line number Diff line number Diff line
@@ -114,6 +114,25 @@ class AParcelableHolder {

    void reset() { AParcel_reset(mParcel.get()); }

    inline bool operator!=(const AParcelableHolder& rhs) const {
        return std::tie(mParcel, mStability) != std::tie(rhs.mParcel, rhs.mStability);
    }
    inline bool operator<(const AParcelableHolder& rhs) const {
        return std::tie(mParcel, mStability) < std::tie(rhs.mParcel, rhs.mStability);
    }
    inline bool operator<=(const AParcelableHolder& rhs) const {
        return std::tie(mParcel, mStability) <= std::tie(rhs.mParcel, rhs.mStability);
    }
    inline bool operator==(const AParcelableHolder& rhs) const {
        return std::tie(mParcel, mStability) == std::tie(rhs.mParcel, rhs.mStability);
    }
    inline bool operator>(const AParcelableHolder& rhs) const {
        return std::tie(mParcel, mStability) > std::tie(rhs.mParcel, rhs.mStability);
    }
    inline bool operator>=(const AParcelableHolder& rhs) const {
        return std::tie(mParcel, mStability) >= std::tie(rhs.mParcel, rhs.mStability);
    }

   private:
    mutable ndk::ScopedAParcel mParcel;
    parcelable_stability_t mStability;