Skip to content

Commit

Permalink
Fixed CMake build
Browse files Browse the repository at this point in the history
  • Loading branch information
snej committed Oct 9, 2019
1 parent cf0060d commit d37d2a6
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
5 changes: 3 additions & 2 deletions API/fleece/FLSlice.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,17 @@ FLSliceResult FLSliceResult_New(size_t);
/** Allocates an FLSliceResult, copying the given slice. */
FLSliceResult FLSlice_Copy(FLSlice);

void _FLBuf_Retain(const void*); // internal; do not call
void _FLBuf_Release(const void*); // internal; do not call

/** Increments the ref-count of a FLSliceResult. */
static inline FLSliceResult FLSliceResult_Retain(FLSliceResult s) {
void _FLBuf_Retain(const void*);
_FLBuf_Retain(s.buf);
return s;
}

/** Decrements the ref-count of a FLSliceResult, freeing its memory if it reached zero. */
static inline void FLSliceResult_Release(FLSliceResult s) {
void _FLBuf_Release(const void*);
_FLBuf_Release(s.buf);
}

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ set(FLEECE_BASE_SRC Fleece/Support/Backtrace.cc
Fleece/Support/RefCounted.cc
Fleece/Support/Writer.cc
Fleece/Support/betterassert.cc
Fleece/Support/FLSlice.cc
Fleece/API_Impl/FLSlice.cc
Fleece/Support/slice.cc
Fleece/Support/varint.cc
vendor/libb64/cdecode.c
Expand Down
2 changes: 2 additions & 0 deletions Fleece.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
274D8255209D1764008BB39F /* RefCounted.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RefCounted.hh; sourceTree = "<group>"; };
2750735D1F4B5F0F003D2CCE /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
275B3595234BE12800FE9CF0 /* FLSlice.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FLSlice.cc; sourceTree = "<group>"; };
275B35A2234E4D3C00FE9CF0 /* cmake */ = {isa = PBXFileReference; lastKnownFileType = folder; path = cmake; sourceTree = "<group>"; };
275C67DB1BFBA0F4008AA9E7 /* Fleece.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Fleece.md; sourceTree = "<group>"; };
275C67DC1BFBA128008AA9E7 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
275CED501D3EF7BE001DE46C /* FleeceException.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FleeceException.cc; sourceTree = "<group>"; };
Expand Down Expand Up @@ -530,6 +531,7 @@
27298E3E1C00F8A9000CFBA8 /* vendor */,
270FA25D1BF53CAD005DCB13 /* Products */,
2750735D1F4B5F0F003D2CCE /* CMakeLists.txt */,
275B35A2234E4D3C00FE9CF0 /* cmake */,
27DE2EE22125FAC600123597 /* Frameworks */,
);
sourceTree = "<group>";
Expand Down
21 changes: 10 additions & 11 deletions Fleece/API_Impl/FLSlice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
// limitations under the License.
//

#include "FLSlice.h"
#include "fleece/FLSlice.h"
#include <atomic>
#include <cstddef>
#include "betterassert.hh"


bool FLSlice_Equal(FLSlice a, FLSlice b) {
Expand Down Expand Up @@ -83,10 +86,6 @@ namespace fleece {
free(self);
}

static sharedBuffer* fromBuf(const void *buf) {
return offsetby((sharedBuffer*)buf, -((long long)offsetof(sharedBuffer, _buf)));
}

inline void retain() noexcept {
assert(isHeapAligned(this));
++_refCount;
Expand All @@ -99,6 +98,10 @@ namespace fleece {
}
};

static sharedBuffer* bufferFromBuf(const void *buf) {
return (sharedBuffer*)((uint8_t*)buf - offsetof(sharedBuffer, _buf));
}

}

using namespace fleece;
Expand Down Expand Up @@ -131,19 +134,15 @@ FLSliceResult FLSlice_Copy(FLSlice s) {
}


void _FLBuf_Retain(const void*);
void _FLBuf_Release(const void*);


void _FLBuf_Retain(const void *buf) {
if (buf)
sharedBuffer::fromBuf(buf)->retain();
bufferFromBuf(buf)->retain();
}


void _FLBuf_Release(const void *buf) {
if (buf)
sharedBuffer::fromBuf(buf)->release();
bufferFromBuf(buf)->release();
}


4 changes: 2 additions & 2 deletions Fleece/Support/Fleece.exp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ _kFLEmptyDict

_FLSlice_Equal
_FLSlice_Compare
_FLSliceResult_Retain
_FLSliceResult_Release
__FLBuf_Retain
__FLBuf_Release

_FLDoc_FromResultData
_FLDoc_FromJSON
Expand Down
8 changes: 4 additions & 4 deletions Fleece/Support/betterassert.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
#endif // assert_always


#ifndef NDEBUG

#undef assert
#undef assert
#ifdef NDEBUG
#define assert(e) ((void)0)
#else
#define assert(e) assert_always(e)

#endif //NDEBUG
3 changes: 2 additions & 1 deletion cmake/platform_base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function(set_source_files_base)
set(
${BASE_SSS_RESULT}
Fleece/API_Impl/Fleece.cc
Fleece/API_Impl/FLSlice.cc
Fleece/Core/Array.cc
Fleece/Core/DeepIterator.cc
Fleece/Core/Dict.cc
Expand Down Expand Up @@ -77,4 +78,4 @@ function(set_test_source_files_base)
Experimental/KeyTree.cc
PARENT_SCOPE
)
endfunction()
endfunction()

0 comments on commit d37d2a6

Please sign in to comment.