aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec/GPBCodedOutputStream.m
diff options
context:
space:
mode:
Diffstat (limited to 'objectivec/GPBCodedOutputStream.m')
-rw-r--r--objectivec/GPBCodedOutputStream.m27
1 files changed, 12 insertions, 15 deletions
diff --git a/objectivec/GPBCodedOutputStream.m b/objectivec/GPBCodedOutputStream.m
index 70142e6f..63ba8068 100644
--- a/objectivec/GPBCodedOutputStream.m
+++ b/objectivec/GPBCodedOutputStream.m
@@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
#import <mach/vm_param.h>
@@ -144,7 +144,7 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
GPBWriteRawByte(state, (int32_t)(value >> 56) & 0xFF);
}
-#if DEBUG && !defined(NS_BLOCK_ASSERTIONS)
+#if defined(DEBUG) && DEBUG && !defined(NS_BLOCK_ASSERTIONS)
+ (void)load {
// This test exists to verify that CFStrings with embedded NULLs will work
// for us. If this Assert fails, all code below that depends on
@@ -178,12 +178,6 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
return [self initWithOutputStream:nil data:data];
}
-- (instancetype)initWithOutputStream:(NSOutputStream *)output
- bufferSize:(size_t)bufferSize {
- NSMutableData *data = [NSMutableData dataWithLength:bufferSize];
- return [self initWithOutputStream:output data:data];
-}
-
// This initializer isn't exposed, but it is the designated initializer.
// Setting OutputStream and NSData is to control the buffering behavior/size
// of the work, but that is more obvious via the bufferSize: version.
@@ -199,21 +193,22 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
return self;
}
-+ (instancetype)streamWithOutputStream:(NSOutputStream *)output
- bufferSize:(size_t)bufferSize {
- return [[[self alloc] initWithOutputStream:output
- bufferSize:bufferSize] autorelease];
-}
-
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output {
+ NSMutableData *data = [NSMutableData dataWithLength:PAGE_SIZE];
return [[[self alloc] initWithOutputStream:output
- bufferSize:PAGE_SIZE] autorelease];
+ data:data] autorelease];
}
+ (instancetype)streamWithData:(NSMutableData *)data {
return [[[self alloc] initWithData:data] autorelease];
}
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
- (void)writeDoubleNoTag:(double)value {
GPBWriteRawLittleEndian64(&state_, GPBConvertDoubleToInt64(value));
}
@@ -992,6 +987,8 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
GPBWriteRawLittleEndian64(&state_, value);
}
+#pragma clang diagnostic pop
+
@end
size_t GPBComputeDoubleSizeNoTag(Float64 value) {