From f3b90d1c60f0acc145d003635d6f1b70a7f6f603 Mon Sep 17 00:00:00 2001 From: Kaitlin Mahar Date: Wed, 15 Apr 2020 17:47:48 -0400 Subject: [PATCH 1/2] disable alignmment --- Sources/CLibMongoC/include/CLibMongoC_bson-config.h | 2 +- Sources/MongoSwift/BSON/Document.swift | 9 --------- Sources/MongoSwift/BSON/DocumentIterator.swift | 5 ----- Sources/MongoSwift/ConnectionString.swift | 5 ++--- etc/generated_headers/bson-config.h | 2 +- 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/Sources/CLibMongoC/include/CLibMongoC_bson-config.h b/Sources/CLibMongoC/include/CLibMongoC_bson-config.h index 5e28608d3..8a64bcf48 100644 --- a/Sources/CLibMongoC/include/CLibMongoC_bson-config.h +++ b/Sources/CLibMongoC/include/CLibMongoC_bson-config.h @@ -128,7 +128,7 @@ /* * Define to 1 if you want extra aligned types in libbson */ -#define BSON_EXTRA_ALIGN 1 +#define BSON_EXTRA_ALIGN 0 #if BSON_EXTRA_ALIGN != 1 # undef BSON_EXTRA_ALIGN #endif diff --git a/Sources/MongoSwift/BSON/Document.swift b/Sources/MongoSwift/BSON/Document.swift index 39dd07529..84221b11e 100644 --- a/Sources/MongoSwift/BSON/Document.swift +++ b/Sources/MongoSwift/BSON/Document.swift @@ -1,13 +1,8 @@ import CLibMongoC import Foundation -#if compiler(>=5.0) -internal typealias BSONPointer = OpaquePointer -internal typealias MutableBSONPointer = OpaquePointer -#else internal typealias BSONPointer = UnsafePointer internal typealias MutableBSONPointer = UnsafeMutablePointer -#endif /// The storage backing a MongoSwift `Document`. public class DocumentStorage { @@ -55,11 +50,7 @@ public struct Document { extension Document { /// Read-only access to the storage's underlying bson_t. internal var _bson: BSONPointer { -#if compiler(>=5.0) - return self._storage._bson -#else return UnsafePointer(self._storage._bson) -#endif } /** diff --git a/Sources/MongoSwift/BSON/DocumentIterator.swift b/Sources/MongoSwift/BSON/DocumentIterator.swift index a9ebe0924..d44ba198d 100644 --- a/Sources/MongoSwift/BSON/DocumentIterator.swift +++ b/Sources/MongoSwift/BSON/DocumentIterator.swift @@ -1,13 +1,8 @@ import CLibMongoC import Foundation -#if compiler(>=5.0) -internal typealias BSONIterPointer = OpaquePointer -internal typealias MutableBSONIterPointer = OpaquePointer -#else internal typealias BSONIterPointer = UnsafePointer internal typealias MutableBSONIterPointer = UnsafeMutablePointer -#endif /// An iterator over the values in a `Document`. public class DocumentIterator: IteratorProtocol { diff --git a/Sources/MongoSwift/ConnectionString.swift b/Sources/MongoSwift/ConnectionString.swift index 9dada4fb4..f44ad119e 100644 --- a/Sources/MongoSwift/ConnectionString.swift +++ b/Sources/MongoSwift/ConnectionString.swift @@ -115,14 +115,13 @@ internal class ConnectionString { internal var authMechanismProperties: Document? { var props = bson_t() return withUnsafeMutablePointer(to: &props) { propsPtr in - let opaquePtr = OpaquePointer(propsPtr) - guard mongoc_uri_get_mechanism_properties(self._uri, opaquePtr) else { + guard mongoc_uri_get_mechanism_properties(self._uri, propsPtr) else { return nil } /// This copy should not be returned directly as its only guaranteed valid for as long as the /// `mongoc_uri_t`, as `props` was statically initialized from data stored in the URI and may contain /// pointers that will be invalidated once the URI is. - let copy = Document(copying: opaquePtr) + let copy = Document(copying: propsPtr) return copy.mapValues { value in // mongoc returns boolean options e.g. CANONICALIZE_HOSTNAME as strings, but they are boolean values. diff --git a/etc/generated_headers/bson-config.h b/etc/generated_headers/bson-config.h index 5e28608d3..8a64bcf48 100644 --- a/etc/generated_headers/bson-config.h +++ b/etc/generated_headers/bson-config.h @@ -128,7 +128,7 @@ /* * Define to 1 if you want extra aligned types in libbson */ -#define BSON_EXTRA_ALIGN 1 +#define BSON_EXTRA_ALIGN 0 #if BSON_EXTRA_ALIGN != 1 # undef BSON_EXTRA_ALIGN #endif From 71605ab2e16227f9925c470dccfa29866442f7d2 Mon Sep 17 00:00:00 2001 From: Kaitlin Mahar Date: Wed, 15 Apr 2020 17:54:01 -0400 Subject: [PATCH 2/2] lint --- Sources/MongoSwift/BSON/Document.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MongoSwift/BSON/Document.swift b/Sources/MongoSwift/BSON/Document.swift index 84221b11e..65a0d8458 100644 --- a/Sources/MongoSwift/BSON/Document.swift +++ b/Sources/MongoSwift/BSON/Document.swift @@ -50,7 +50,7 @@ public struct Document { extension Document { /// Read-only access to the storage's underlying bson_t. internal var _bson: BSONPointer { - return UnsafePointer(self._storage._bson) + UnsafePointer(self._storage._bson) } /**