/work/obj-fuzz/dist/include/mozilla/Range.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_Range_h |
8 | | #define mozilla_Range_h |
9 | | |
10 | | #include "mozilla/RangedPtr.h" |
11 | | #include "mozilla/TypeTraits.h" |
12 | | #include "mozilla/Span.h" |
13 | | |
14 | | #include <stddef.h> |
15 | | |
16 | | namespace mozilla { |
17 | | |
18 | | // Range<T> is a tuple containing a pointer and a length. |
19 | | template <typename T> |
20 | | class Range |
21 | | { |
22 | | const RangedPtr<T> mStart; |
23 | | const RangedPtr<T> mEnd; |
24 | | |
25 | | public: |
26 | | Range() : mStart(nullptr, 0), mEnd(nullptr, 0) {} |
27 | | Range(T* aPtr, size_t aLength) |
28 | | : mStart(aPtr, aPtr, aPtr + aLength), |
29 | | mEnd(aPtr + aLength, aPtr, aPtr + aLength) |
30 | 3.26M | {} mozilla::Range<unsigned char>::Range(unsigned char*, unsigned long) Line | Count | Source | 30 | 3 | {} |
Unexecuted instantiation: mozilla::Range<char16_t>::Range(char16_t*, unsigned long) Unexecuted instantiation: mozilla::Range<XVisualInfo>::Range(XVisualInfo*, unsigned long) Unexecuted instantiation: mozilla::Range<mozilla::wr::ImageKey>::Range(mozilla::wr::ImageKey*, unsigned long) Unexecuted instantiation: mozilla::Range<mozilla::gfx::FontVariation const>::Range(mozilla::gfx::FontVariation const*, unsigned long) mozilla::Range<unsigned char const>::Range(unsigned char const*, unsigned long) Line | Count | Source | 30 | 3.26M | {} |
Unexecuted instantiation: mozilla::Range<mozilla::wr::GlyphInstance const>::Range(mozilla::wr::GlyphInstance const*, unsigned long) Unexecuted instantiation: mozilla::Range<mozilla::wr::BorderSide const>::Range(mozilla::wr::BorderSide const*, unsigned long) Unexecuted instantiation: mozilla::Range<int>::Range(int*, unsigned long) mozilla::Range<char16_t const>::Range(char16_t const*, unsigned long) Line | Count | Source | 30 | 4.70k | {} |
Unexecuted instantiation: mozilla::Range<js::wasm::ValType const>::Range(js::wasm::ValType const*, unsigned long) |
31 | | Range(const RangedPtr<T>& aStart, const RangedPtr<T>& aEnd) |
32 | | : mStart(aStart.get(), aStart.get(), aEnd.get()), |
33 | | mEnd(aEnd.get(), aStart.get(), aEnd.get()) |
34 | 0 | { |
35 | 0 | // Only accept two RangedPtrs within the same range. |
36 | 0 | aStart.checkIdenticalRange(aEnd); |
37 | 0 | MOZ_ASSERT(aStart <= aEnd); |
38 | 0 | } Unexecuted instantiation: mozilla::Range<unsigned char>::Range(mozilla::RangedPtr<unsigned char> const&, mozilla::RangedPtr<unsigned char> const&) Unexecuted instantiation: mozilla::Range<unsigned char const>::Range(mozilla::RangedPtr<unsigned char const> const&, mozilla::RangedPtr<unsigned char const> const&) Unexecuted instantiation: mozilla::Range<mozilla::Keyframe>::Range(mozilla::RangedPtr<mozilla::Keyframe> const&, mozilla::RangedPtr<mozilla::Keyframe> const&) |
39 | | |
40 | | template<typename U, |
41 | | class = typename EnableIf<IsConvertible<U (*)[], T (*)[]>::value, |
42 | | int>::Type> |
43 | | MOZ_IMPLICIT Range(const Range<U>& aOther) |
44 | | : mStart(aOther.mStart), |
45 | | mEnd(aOther.mEnd) |
46 | | {} |
47 | | |
48 | | MOZ_IMPLICIT Range(Span<T> aSpan) |
49 | | : Range(aSpan.Elements(), aSpan.Length()) |
50 | | { |
51 | | } |
52 | | |
53 | | template<typename U, |
54 | | class = typename EnableIf<IsConvertible<U (*)[], T (*)[]>::value, |
55 | | int>::Type> |
56 | | MOZ_IMPLICIT Range(const Span<U>& aSpan) |
57 | | : Range(aSpan.Elements(), aSpan.Length()) |
58 | | { |
59 | | } |
60 | | |
61 | 3.26M | RangedPtr<T> begin() const { return mStart; } Unexecuted instantiation: mozilla::Range<unsigned char>::begin() const Unexecuted instantiation: mozilla::Range<XVisualInfo>::begin() const Unexecuted instantiation: mozilla::Range<mozilla::gfx::FontVariation const>::begin() const mozilla::Range<unsigned char const>::begin() const Line | Count | Source | 61 | 3.26M | RangedPtr<T> begin() const { return mStart; } |
Unexecuted instantiation: mozilla::Range<mozilla::Keyframe>::begin() const Unexecuted instantiation: mozilla::Range<char16_t const>::begin() const Unexecuted instantiation: mozilla::Range<char16_t>::begin() const |
62 | 0 | RangedPtr<T> end() const { return mEnd; } Unexecuted instantiation: mozilla::Range<XVisualInfo>::end() const Unexecuted instantiation: mozilla::Range<unsigned char const>::end() const Unexecuted instantiation: mozilla::Range<mozilla::Keyframe>::end() const Unexecuted instantiation: mozilla::Range<char16_t const>::end() const |
63 | 3.26M | size_t length() const { return mEnd - mStart; } mozilla::Range<unsigned char>::length() const Line | Count | Source | 63 | 6 | size_t length() const { return mEnd - mStart; } |
Unexecuted instantiation: mozilla::Range<mozilla::gfx::FontVariation const>::length() const mozilla::Range<unsigned char const>::length() const Line | Count | Source | 63 | 3.26M | size_t length() const { return mEnd - mStart; } |
Unexecuted instantiation: mozilla::Range<mozilla::wr::BorderSide const>::length() const Unexecuted instantiation: mozilla::Range<mozilla::wr::GlyphInstance const>::length() const Unexecuted instantiation: mozilla::Range<mozilla::Keyframe>::length() const Unexecuted instantiation: mozilla::Range<int>::length() const mozilla::Range<char16_t const>::length() const Line | Count | Source | 63 | 4.70k | size_t length() const { return mEnd - mStart; } |
Unexecuted instantiation: mozilla::Range<char16_t>::length() const Unexecuted instantiation: mozilla::Range<js::wasm::ValType const>::length() const |
64 | | |
65 | 1.65M | T& operator[](size_t aOffset) const { return mStart[aOffset]; } mozilla::Range<unsigned char>::operator[](unsigned long) const Line | Count | Source | 65 | 1.60M | T& operator[](size_t aOffset) const { return mStart[aOffset]; } |
Unexecuted instantiation: mozilla::Range<char16_t>::operator[](unsigned long) const Unexecuted instantiation: mozilla::Range<mozilla::wr::ImageKey>::operator[](unsigned long) const Unexecuted instantiation: mozilla::Range<mozilla::wr::BorderSide const>::operator[](unsigned long) const Unexecuted instantiation: mozilla::Range<mozilla::wr::GlyphInstance const>::operator[](unsigned long) const Unexecuted instantiation: mozilla::Range<mozilla::Keyframe>::operator[](unsigned long) const Unexecuted instantiation: mozilla::Range<unsigned char const>::operator[](unsigned long) const mozilla::Range<char16_t const>::operator[](unsigned long) const Line | Count | Source | 65 | 43.9k | T& operator[](size_t aOffset) const { return mStart[aOffset]; } |
Unexecuted instantiation: mozilla::Range<js::wasm::ValType const>::operator[](unsigned long) const |
66 | | |
67 | | explicit operator bool() const { return mStart != nullptr; } |
68 | | |
69 | 0 | operator Span<T>() { return Span<T>(mStart.get(), length()); } |
70 | | |
71 | 0 | operator Span<const T>() const { return Span<T>(mStart.get(), length()); } |
72 | | }; |
73 | | |
74 | | template<class T> |
75 | | Span<T> |
76 | | MakeSpan(Range<T>& aRange) |
77 | 0 | { |
78 | 0 | return aRange; |
79 | 0 | } |
80 | | |
81 | | template<class T> |
82 | | Span<const T> |
83 | | MakeSpan(const Range<T>& aRange) |
84 | | { |
85 | | return aRange; |
86 | | } |
87 | | |
88 | | } // namespace mozilla |
89 | | |
90 | | #endif /* mozilla_Range_h */ |