Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three fixes needed for latest LiteCore VV work #190

Merged
merged 3 commits into from
Oct 26, 2023
Merged
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
6 changes: 6 additions & 0 deletions API/fleece/FLExpert.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ extern "C" {
/** \defgroup Obscure Rarely-needed or advanced functions
@{ */

/** For use with \ref FLDoc_FromResultData. This option prevents the function from parsing the
data at all; you are responsible for locating the FLValues in it.
This is for the case where you have trusted data in a custom format that contains Fleece-
encoded data within it. You still need an FLDoc to access the data safely (especially to
retain FLValues), but it can't be parsed as-is. */
#define kFLTrustedDontParse FLTrust(-1)

/** \name Delta Compression
@{
Expand Down
8 changes: 7 additions & 1 deletion Fleece/Mutable/HeapDict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace fleece { namespace impl { namespace internal {

HeapDict::HeapDict(const Dict *d)
HeapDict::HeapDict(const Dict *d, CopyFlags flags)
:HeapCollection(kDictTag)
{
if (d) {
Expand All @@ -30,9 +30,15 @@ namespace fleece { namespace impl { namespace internal {
_source = hd->_source;
_map = hd->_map;
_backingSlices = hd->_backingSlices;
} else if (flags & kCopyImmutables) {
_count = 0;
for (Dict::iterator i(d); i; ++i)
set(i.keyString(), i.value());
} else {
_source = d;
}
if (flags)
copyChildren(flags);
if (_source)
_sharedKeys = _source->sharedKeys();
}
Expand Down
2 changes: 1 addition & 1 deletion Fleece/Mutable/HeapDict.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace fleece { namespace impl { namespace internal {

class HeapDict : public HeapCollection {
public:
HeapDict(const Dict* =nullptr);
HeapDict(const Dict* =nullptr, CopyFlags flags =kDefaultCopy);

static MutableDict* asMutableDict(HeapDict *a) {return (MutableDict*)asValue(a);}
MutableDict* asMutableDict() const {return (MutableDict*)asValue();}
Expand Down
5 changes: 1 addition & 4 deletions Fleece/Mutable/MutableDict.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ namespace fleece { namespace impl {
public:

static Retained<MutableDict> newDict(const Dict *d =nullptr, CopyFlags flags =kDefaultCopy) {
auto hd = retained(new internal::HeapDict(d));
if (flags)
hd->copyChildren(flags);
return hd->asMutableDict();
return retained(new internal::HeapDict(d, flags))->asMutableDict();
}

Retained<MutableDict> copy(CopyFlags f =kDefaultCopy) {return newDict(this, f);}
Expand Down
7 changes: 5 additions & 2 deletions Fleece/Support/slice_stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ namespace fleece {
constexpr slice_istream(const alloc_slice &s) noexcept :slice(s) { }
constexpr slice_istream(const void* b, size_t s) noexcept STEPOVER :slice(b, s) {}
constexpr slice_istream(const void* s NONNULL, const void* e NONNULL) noexcept STEPOVER
:slice(s, e) { }
:slice(s, e) { }
constexpr slice_istream(slice_istream&&) = default;
slice_istream& operator=(slice_istream&&) = default;

/// The number of bytes remaining to be read.
size_t bytesRemaining() const noexcept FLPURE {return size;}

Expand Down Expand Up @@ -232,6 +235,6 @@ namespace fleece {
// Pass-by-value is intentionally forbidden to make passing a `slice_istream` as a
// parameter illegal. That's because its behavior would be wrong: reads made by the
// callee would not be reflected in the caller. Always pass a reference, `slice_istream&`.
slice_istream(const slice_istream&) = default;
slice_istream(const slice_istream&) = delete;
};
}
Loading