THRIFT-2905 Cocoa compiler should have option to produce "modern" Objective-C
Client: Cocoa (ObjectiveC & Swift)
Author: Kevin Wooten <kevin@wooten.com>

This closes #539
diff --git a/lib/cocoa/src/protocol/TProtocol.h b/lib/cocoa/src/protocol/TProtocol.h
index 281239d..841059f 100644
--- a/lib/cocoa/src/protocol/TProtocol.h
+++ b/lib/cocoa/src/protocol/TProtocol.h
@@ -22,127 +22,143 @@
 #import "TTransport.h"
 
 
-enum {
-  TMessageType_CALL = 1,
-  TMessageType_REPLY = 2,
-  TMessageType_EXCEPTION = 3,
-  TMessageType_ONEWAY = 4
+NS_ASSUME_NONNULL_BEGIN
+
+
+typedef NS_ENUM (int, TMessageType) {
+  TMessageTypeCALL = 1,
+  TMessageTypeREPLY = 2,
+  TMessageTypeEXCEPTION = 3,
+  TMessageTypeONEWAY = 4
 };
 
-enum {
-  TType_STOP   = 0,
-  TType_VOID   = 1,
-  TType_BOOL   = 2,
-  TType_BYTE   = 3,
-  TType_DOUBLE = 4,
-  TType_I16    = 6,
-  TType_I32    = 8,
-  TType_I64    = 10,
-  TType_STRING = 11,
-  TType_STRUCT = 12,
-  TType_MAP    = 13,
-  TType_SET    = 14,
-  TType_LIST   = 15
+typedef NS_ENUM (int, TType) {
+  TTypeSTOP   = 0,
+  TTypeVOID   = 1,
+  TTypeBOOL   = 2,
+  TTypeBYTE   = 3,
+  TTypeDOUBLE = 4,
+  TTypeI16    = 6,
+  TTypeI32    = 8,
+  TTypeI64    = 10,
+  TTypeSTRING = 11,
+  TTypeSTRUCT = 12,
+  TTypeMAP    = 13,
+  TTypeSET    = 14,
+  TTypeLIST   = 15
 };
 
 
 @protocol TProtocol <NSObject>
 
-- (id <TTransport>) transport;
+-(id <TTransport>) transport;
 
-- (void) readMessageBeginReturningName: (NSString **) name
-                                  type: (int *) type
-                            sequenceID: (int *) sequenceID;
-- (void) readMessageEnd;
+-(BOOL) readMessageBeginReturningName:(NSString *__nullable __autoreleasing *__nullable)name
+                                 type:(nullable SInt32 *)type
+                           sequenceID:(nullable SInt32 *)sequenceID
+                                error:(NSError *__autoreleasing *)error;
+-(BOOL) readMessageEnd:(NSError *__autoreleasing *)error;
 
-- (void) readStructBeginReturningName: (NSString **) name;
-- (void) readStructEnd;
+-(BOOL) readStructBeginReturningName:(NSString *__nullable __autoreleasing *__nullable)name
+                               error:(NSError *__autoreleasing *)error;
+-(BOOL) readStructEnd:(NSError *__autoreleasing *)error;
 
-- (void) readFieldBeginReturningName: (NSString **) name
-                                type: (int *) fieldType
-                             fieldID: (int *) fieldID;
-- (void) readFieldEnd;
+-(BOOL) readFieldBeginReturningName:(NSString *__nullable __autoreleasing *__nullable)name
+                               type:(SInt32 *)fieldType
+                            fieldID:(nullable SInt32 *)fieldID
+                              error:(NSError *__autoreleasing *)error;
+-(BOOL) readFieldEnd:(NSError *__autoreleasing *)error;
 
-- (NSString *) readString;
+-(BOOL) readString:(NSString *__nonnull __autoreleasing *__nonnull)value error:(NSError **)error;
 
-- (BOOL) readBool;
+-(BOOL) readBool:(BOOL *)value error:(NSError *__autoreleasing *)error;
 
-- (unsigned char) readByte;
+-(BOOL) readByte:(UInt8 *)value error:(NSError *__autoreleasing *)error;
 
-- (short) readI16;
+-(BOOL) readI16:(SInt16 *)value error:(NSError *__autoreleasing *)error;
 
-- (int32_t) readI32;
+-(BOOL) readI32:(SInt32 *)value error:(NSError *__autoreleasing *)error;
 
-- (int64_t) readI64;
+-(BOOL) readI64:(SInt64 *)value error:(NSError *__autoreleasing *)error;
 
-- (double) readDouble;
+-(BOOL) readDouble:(double *)value error:(NSError *__autoreleasing *)error;
 
-- (NSData *) readBinary;
+-(BOOL) readBinary:(NSData *__nonnull __autoreleasing *__nonnull)value error:(NSError **)error;
 
-- (void) readMapBeginReturningKeyType: (int *) keyType
-                            valueType: (int *) valueType
-                                 size: (int *) size;
-- (void) readMapEnd;
+-(BOOL) readMapBeginReturningKeyType:(nullable SInt32 *)keyType
+                           valueType:(nullable SInt32 *)valueType
+                                size:(SInt32 *)size
+                               error:(NSError *__autoreleasing *)error;
+-(BOOL) readMapEnd:(NSError *__autoreleasing *)error;
 
 
-- (void) readSetBeginReturningElementType: (int *) elementType
-                                     size: (int *) size;
-- (void) readSetEnd;
+-(BOOL) readSetBeginReturningElementType:(nullable SInt32 *)elementType
+                                    size:(SInt32 *)size
+                                   error:(NSError *__autoreleasing *)error;
+-(BOOL) readSetEnd:(NSError *__autoreleasing *)error;
 
 
-- (void) readListBeginReturningElementType: (int *) elementType
-                                      size: (int *) size;
-- (void) readListEnd;
+-(BOOL) readListBeginReturningElementType:(nullable SInt32 *)elementType
+                                     size:(SInt32 *)size
+                                    error:(NSError *__autoreleasing *)error;
+-(BOOL) readListEnd:(NSError *__autoreleasing *)error;
 
 
-- (void) writeMessageBeginWithName: (NSString *) name
-                              type: (int) messageType
-                        sequenceID: (int) sequenceID;
-- (void) writeMessageEnd;
+-(BOOL) writeMessageBeginWithName:(NSString *)name
+                             type:(SInt32)messageType
+                       sequenceID:(SInt32)sequenceID
+                            error:(NSError *__autoreleasing *)error;
+-(BOOL) writeMessageEnd:(NSError *__autoreleasing *)error;
 
-- (void) writeStructBeginWithName: (NSString *) name;
-- (void) writeStructEnd;
+-(BOOL) writeStructBeginWithName:(NSString *)name error:(NSError **)error;
+-(BOOL) writeStructEnd:(NSError *__autoreleasing *)error;
 
-- (void) writeFieldBeginWithName: (NSString *) name
-                            type: (int) fieldType
-                         fieldID: (int) fieldID;
+-(BOOL) writeFieldBeginWithName:(NSString *)name
+                           type:(SInt32)fieldType
+                        fieldID:(SInt32)fieldID
+                          error:(NSError *__autoreleasing *)error;
 
-- (void) writeI32: (int32_t) value;
+-(BOOL) writeI32:(SInt32)value error:(NSError *__autoreleasing *)error;
 
-- (void) writeI64: (int64_t) value;
+-(BOOL) writeI64:(SInt64)value error:(NSError *__autoreleasing *)error;
 
-- (void) writeI16: (short) value;
+-(BOOL) writeI16:(short)value error:(NSError *__autoreleasing *)error;
 
-- (void) writeByte: (uint8_t) value;
+-(BOOL) writeByte:(UInt8)value error:(NSError *__autoreleasing *)error;
 
-- (void) writeString: (NSString *) value;
+-(BOOL) writeString:(NSString *)value error:(NSError *__autoreleasing *)error;
 
-- (void) writeDouble: (double) value;
+-(BOOL) writeDouble:(double)value error:(NSError *__autoreleasing *)error;
 
-- (void) writeBool: (BOOL) value;
+-(BOOL) writeBool:(BOOL)value error:(NSError *__autoreleasing *)error;
 
-- (void) writeBinary: (NSData *) data;
+-(BOOL) writeBinary:(NSData *)data error:(NSError *__autoreleasing *)error;
 
-- (void) writeFieldStop;
+-(BOOL) writeFieldStop:(NSError *__autoreleasing *)error;
 
-- (void) writeFieldEnd;
+-(BOOL) writeFieldEnd:(NSError *__autoreleasing *)error;
 
-- (void) writeMapBeginWithKeyType: (int) keyType
-                        valueType: (int) valueType
-                             size: (int) size;
-- (void) writeMapEnd;
+-(BOOL) writeMapBeginWithKeyType:(SInt32)keyType
+                       valueType:(SInt32)valueType
+                            size:(SInt32)size
+                           error:(NSError *__autoreleasing *)error;
+-(BOOL) writeMapEnd:(NSError *__autoreleasing *)error;
 
 
-- (void) writeSetBeginWithElementType: (int) elementType
-                                 size: (int) size;
-- (void) writeSetEnd;
+-(BOOL) writeSetBeginWithElementType:(SInt32)elementType
+                                size:(SInt32)size
+                               error:(NSError *__autoreleasing *)error;
+-(BOOL) writeSetEnd:(NSError *__autoreleasing *)error;
 
 
-- (void) writeListBeginWithElementType: (int) elementType
-                                  size: (int) size;
+-(BOOL) writeListBeginWithElementType:(SInt32)elementType
+                                 size:(SInt32)size
+                                error:(NSError *__autoreleasing *)error;
 
-- (void) writeListEnd;
+-(BOOL) writeListEnd:(NSError *__autoreleasing *)error;
 
 
 @end
 
+
+NS_ASSUME_NONNULL_END