http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.m deleted file mode 100644 index 45b0ef3..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TCompactProtocol.m +++ /dev/null @@ -1,687 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TCompactProtocol.h" -#import "TObjective-C.h" -#import "TProtocolException.h" - -static const uint8_t COMPACT_PROTOCOL_ID = 0x82; -static const uint8_t COMPACT_VERSION = 1; -static const uint8_t COMPACT_VERSION_MASK = 0x1F; // 0001 1111 -static const uint8_t COMPACT_TYPE_MASK = 0xE0; // 1110 0000 -static const uint8_t COMPACT_TYPE_BITS = 0x07; // 0000 0111 -static const int COMPACT_TYPE_SHIFT_AMOUNT = 5; - -enum { - TCType_STOP = 0x00, - TCType_BOOLEAN_TRUE = 0x01, - TCType_BOOLEAN_FALSE = 0x02, - TCType_BYTE = 0x03, - TCType_I16 = 0x04, - TCType_I32 = 0x05, - TCType_I64 = 0x06, - TCType_DOUBLE = 0x07, - TCType_BINARY = 0x08, - TCType_LIST = 0x09, - TCType_SET = 0x0A, - TCType_MAP = 0x0B, - TCType_STRUCT = 0x0C, -}; - -@implementation TCompactProtocolFactory - -+ (TCompactProtocolFactory *) sharedFactory -{ - static TCompactProtocolFactory * gSharedFactory = nil; - if (gSharedFactory == nil) { - gSharedFactory = [[TCompactProtocolFactory alloc] init]; - } - - return gSharedFactory; -} - -- (TCompactProtocol *) newProtocolOnTransport: (id <TTransport>) transport -{ - return [[TCompactProtocol alloc] initWithTransport: transport]; -} - -@end - -@implementation TCompactProtocol { - NSMutableArray * lastField; - short lastFieldId; - id <TTransport> mTransport; - - NSString * boolFieldName; - NSNumber * boolFieldType; - NSNumber * boolFieldId; - NSNumber * booleanValue; -} - -- (id) init -{ - self = [super init]; - - if (self != nil) { - lastField = [[NSMutableArray alloc] init]; - } - - return self; -} - -- (id) initWithTransport: (id <TTransport>) transport -{ - self = [self init]; - - if (self != nil) { - mTransport = [transport retain_stub]; - } - - return self; -} - -- (void) dealloc -{ - [lastField release_stub]; - [mTransport release_stub]; - [boolFieldName release_stub]; - [boolFieldType release_stub]; - [boolFieldId release_stub]; - [booleanValue release_stub]; - - [super dealloc_stub]; -} - -- (id <TTransport>) transport -{ - return mTransport; -} - -- (void) writeByteDirect: (int8_t) n -{ - [mTransport write: (uint8_t *)&n offset: 0 length: 1]; -} - -- (void)writeVarint32: (uint32_t) n -{ - uint8_t i32buf[5] = {0}; - uint32_t idx = 0; - - while (true) { - if ((n & ~0x7F) == 0) { - i32buf[idx++] = (uint8_t)n; - break; - } else { - i32buf[idx++] = (uint8_t)((n & 0x7F) | 0x80); - n >>= 7; - } - } - - [mTransport write: i32buf offset: 0 length: idx]; -} - -- (void) writeMessageBeginWithName: (NSString *) name - type: (int) messageType - sequenceID: (int) sequenceID -{ - [self writeByteDirect: COMPACT_PROTOCOL_ID]; - [self writeByteDirect: (uint8_t)((COMPACT_VERSION & COMPACT_VERSION_MASK) | - ((((uint32_t)messageType) << COMPACT_TYPE_SHIFT_AMOUNT) & COMPACT_TYPE_MASK))]; - [self writeVarint32: (uint32_t)sequenceID]; - [self writeString: name]; -} - -- (void) writeStructBeginWithName: (NSString *) name -{ - [lastField addObject: [NSNumber numberWithShort: lastFieldId]]; - lastFieldId = 0; -} - -- (void) writeStructEnd -{ - lastFieldId = [[lastField lastObject] shortValue]; - [lastField removeLastObject]; -} - -- (void) writeFieldBeginWithName: (NSString *) name - type: (int) fieldType - fieldID: (int) fieldID -{ - if (fieldType == TType_BOOL) { - boolFieldName = [name copy]; - boolFieldType = [[NSNumber numberWithInt: fieldType] retain_stub]; - boolFieldId = [[NSNumber numberWithInt: fieldID] retain_stub]; - } else { - [self writeFieldBeginInternalWithName: name - type: fieldType - fieldID: fieldID - typeOverride: 0xFF]; - } -} - -- (void) writeFieldBeginInternalWithName: (NSString *) name - type: (int) fieldType - fieldID: (int) fieldID - typeOverride: (uint8_t) typeOverride -{ - uint8_t typeToWrite = typeOverride == 0xFF ? [self compactTypeForTType: fieldType] : typeOverride; - - // check if we can use delta encoding for the field id - if (fieldID > lastFieldId && fieldID - lastFieldId <= 15) { - // Write them together - [self writeByteDirect: (fieldID - lastFieldId) << 4 | typeToWrite]; - } else { - // Write them separate - [self writeByteDirect: typeToWrite]; - [self writeI16: fieldID]; - } - - lastFieldId = fieldID; -} - -- (void) writeFieldStop -{ - [self writeByteDirect: TCType_STOP]; -} - -- (void) writeMapBeginWithKeyType: (int) keyType - valueType: (int) valueType - size: (int) size -{ - if (size == 0) { - [self writeByteDirect: 0]; - } else { - [self writeVarint32: (uint32_t)size]; - [self writeByteDirect: [self compactTypeForTType: keyType] << 4 | [self compactTypeForTType: valueType]]; - } -} - -- (void) writeListBeginWithElementType: (int) elementType - size: (int) size -{ - [self writeCollectionBeginWithElementType: elementType size: size]; -} - -- (void) writeSetBeginWithElementType: (int) elementType - size: (int) size -{ - [self writeCollectionBeginWithElementType: elementType size: size]; -} - -- (void) writeBool: (BOOL) b -{ - if (boolFieldId != nil && boolFieldName != nil && boolFieldType != nil) { - // we haven't written the field header yet - [self writeFieldBeginInternalWithName: boolFieldName - type: [boolFieldType intValue] - fieldID: [boolFieldId intValue] - typeOverride: b ? TCType_BOOLEAN_TRUE : TCType_BOOLEAN_FALSE]; - - [boolFieldId release_stub]; - [boolFieldName release_stub]; - [boolFieldType release_stub]; - - boolFieldId = nil; - boolFieldName = nil; - boolFieldType = nil; - } else { - // we're not part of a field, so just Write the value. - [self writeByteDirect: b ? TCType_BOOLEAN_TRUE : TCType_BOOLEAN_FALSE]; - } -} - -- (void) writeByte: (uint8_t) value -{ - [self writeByteDirect: value]; -} - -- (void) writeI16: (int16_t) value -{ - [self writeVarint32: [self i32ToZigZag: value]]; -} - -- (void) writeI32: (int32_t) value -{ - [self writeVarint32: [self i32ToZigZag: value]]; -} - -- (void) writeI64: (int64_t) value -{ - [self writeVarint64: [self i64ToZigZag: value]]; -} - -- (void) writeDouble: (double) value -{ - //Safe bit-casting double->uint64 - - uint64_t bits = 0; - memcpy(&bits, &value, 8); - - bits = OSSwapHostToLittleInt64(bits); - - [mTransport write: (uint8_t *)&bits offset: 0 length: 8]; -} - -- (void) writeString: (NSString *) value -{ - [self writeBinary: [value dataUsingEncoding: NSUTF8StringEncoding]]; -} - -- (void) writeBinary: (NSData *) data -{ - [self writeVarint32: (uint32_t)data.length]; - [mTransport write: data.bytes offset: 0 length: data.length]; -} - -- (void) writeMessageEnd {} -- (void) writeMapEnd {} -- (void) writeListEnd {} -- (void) writeSetEnd {} -- (void) writeFieldEnd {} - -- (void) writeCollectionBeginWithElementType: (int) elementType - size: (int) size -{ - if (size <= 14) { - [self writeByteDirect: size << 4 | [self compactTypeForTType: elementType]]; - } else { - [self writeByteDirect: 0xf0 | [self compactTypeForTType: elementType]]; - [self writeVarint32: (uint32_t)size]; - } -} - -- (void) writeVarint64: (uint64_t) n -{ - uint8_t varint64out[10] = {0}; - int idx = 0; - - while (true) { - if ((n & ~0x7FL) == 0) { - varint64out[idx++] = (uint8_t)n; - break; - } else { - varint64out[idx++] = (uint8_t)((n & 0x7F) | 0x80); - n >>= 7; - } - } - - [mTransport write: varint64out offset: 0 length: idx]; -} - -- (uint32_t) i32ToZigZag: (int32_t) n -{ - /* - ZigZag encoding maps signed integers to unsigned integers so that - numbers with a small absolute value (for instance, -1) have - a small varint encoded value too. It does this in a way that - "zig-zags" back and forth through the positive and negative integers, - so that -1 is encoded as 1, 1 is encoded as 2, -2 is encoded as 3, and so on - */ - return (uint32_t)(n << 1) ^ (uint32_t)(n >> 31); -} - -- (uint64_t) i64ToZigZag: (int64_t) n -{ - return (uint64_t)(n << 1) ^ (uint64_t)(n >> 63); -} - -- (void) readMessageBeginReturningName: (NSString **) pname - type: (int *) ptype - sequenceID: (int *) psequenceID -{ - uint8_t protocolId = [self readByte]; - if (protocolId != COMPACT_PROTOCOL_ID) { - @throw [TProtocolException exceptionWithName: @"TProtocolException" - reason: [NSString stringWithFormat: @"Expected protocol id %X but got %X", COMPACT_PROTOCOL_ID, protocolId]]; - } - - uint8_t versionAndType = [self readByte]; - uint8_t version = versionAndType & COMPACT_VERSION_MASK; - if (version != COMPACT_VERSION) { - @throw [TProtocolException exceptionWithName: @"TProtocolException" - reason: [NSString stringWithFormat: @"Expected version %d but got %d", COMPACT_VERSION, version]]; - } - - int type = (versionAndType >> COMPACT_TYPE_SHIFT_AMOUNT) & COMPACT_TYPE_BITS; - int sequenceID = (int)[self readVarint32]; - NSString* name = [self readString]; - - if (ptype != NULL) { - *ptype = type; - } - if (psequenceID != NULL) { - *psequenceID = sequenceID; - } - if (pname != NULL) { - *pname = name; - } -} - -- (void) readStructBeginReturningName: (NSString **) pname -{ - [lastField addObject: [NSNumber numberWithShort: lastFieldId]]; - lastFieldId = 0; - - if (pname != NULL) { - *pname = @""; - } -} - -- (void) readStructEnd -{ - lastFieldId = [[lastField lastObject] shortValue]; - [lastField removeLastObject]; -} - -- (void) readFieldBeginReturningName: (NSString **) pname - type: (int *) pfieldType - fieldID: (int *) pfieldID -{ - uint8_t byte = [self readByte]; - uint8_t type = byte & 0x0f; - - // if it's a stop, then we can return immediately, as the struct is over. - if (type == TCType_STOP) { - if (pname != NULL) { - *pname = @""; - } - if (pfieldType != NULL) { - *pfieldType = TType_STOP; - } - if (pfieldID != NULL) { - *pfieldID = 0; - } - return; - } - - short fieldId = 0; - - // mask off the 4 MSB of the type header. it could contain a field id delta. - short modifier = (byte & 0xf0) >> 4; - if (modifier == 0) { - // not a delta. look ahead for the zigzag varint field id. - fieldId = [self readI16]; - } else { - // has a delta. add the delta to the last Read field id. - fieldId = lastFieldId + modifier; - } - - int fieldType = [self ttypeForCompactType: type]; - - if (pname != NULL) { - *pname = @""; - } - if (pfieldType != NULL) { - *pfieldType = fieldType; - } - if (pfieldID != NULL) { - *pfieldID = fieldId; - } - - // if this happens to be a boolean field, the value is encoded in the type - if (type == TCType_BOOLEAN_TRUE || - type == TCType_BOOLEAN_FALSE) { - // save the boolean value in a special instance variable. - booleanValue = [[NSNumber numberWithBool: type == TCType_BOOLEAN_TRUE] retain_stub]; - } - - // push the new field onto the field stack so we can keep the deltas going. - lastFieldId = fieldId; -} - -- (void) readMapBeginReturningKeyType: (int *) pkeyType - valueType: (int *) pvalueType - size: (int *) psize -{ - uint8_t keyAndValueType = 0; - int size = (int)[self readVarint32]; - if (size != 0) { - keyAndValueType = [self readByte]; - } - - int keyType = [self ttypeForCompactType: keyAndValueType >> 4]; - int valueType = [self ttypeForCompactType: keyAndValueType & 0xf]; - - if (pkeyType != NULL) { - *pkeyType = keyType; - } - if (pvalueType != NULL) { - *pvalueType = valueType; - } - if (psize != NULL) { - *psize = size; - } -} - -- (void) readListBeginReturningElementType: (int *) pelementType - size: (int *) psize -{ - uint8_t size_and_type = [self readByte]; - int size = (size_and_type >> 4) & 0x0f; - if (size == 15) { - size = (int)[self readVarint32]; - } - - int elementType = [self ttypeForCompactType: size_and_type & 0x0f]; - - if (pelementType != NULL) { - *pelementType = elementType; - } - if (psize != NULL) { - *psize = size; - } -} - -- (void) readSetBeginReturningElementType: (int *) pelementType - size: (int *) psize -{ - [self readListBeginReturningElementType: pelementType size: psize]; -} - -- (BOOL) readBool -{ - if (booleanValue != nil) { - BOOL result = [booleanValue boolValue]; - [booleanValue release_stub]; - booleanValue = nil; - return result; - } else { - return [self readByte] == TCType_BOOLEAN_TRUE; - } -} - -- (uint8_t) readByte -{ - uint8_t buf = 0; - [mTransport readAll: &buf offset: 0 length: 1]; - return buf; -} - -- (int16_t) readI16 -{ - return (int16_t)[self zigZagToi32: [self readVarint32]]; -} - -- (int32_t) readI32 -{ - return [self zigZagToi32: [self readVarint32]]; -} - -- (int64_t) readI64 -{ - return [self zigZagToi64: [self readVarint64]]; -} - -- (double) readDouble -{ - uint64_t bits = 0; - [mTransport readAll: (uint8_t *)&bits offset: 0 length: 8]; - bits = OSSwapLittleToHostInt64(bits); - - double result = 0; - memcpy(&result, &bits, 8); - - return result; -} - -- (NSString *) readString -{ - int length = (int)[self readVarint32]; - if (length == 0) { - return @""; - } - - return [[[NSString alloc] initWithData: [self readBinary: length] - encoding: NSUTF8StringEncoding] autorelease_stub]; -} - -- (NSData *) readBinary -{ - return [self readBinary: (int)[self readVarint32]]; -} - -- (NSData *) readBinary: (int) length -{ - if (length == 0) { - return [NSData data]; - } - - NSMutableData* buf = [NSMutableData dataWithLength: length]; - [mTransport readAll: buf.mutableBytes offset: 0 length: length]; - return buf; -} - -- (void) readMessageEnd {} -- (void) readFieldEnd {} -- (void) readMapEnd {} -- (void) readListEnd {} -- (void) readSetEnd {} - -- (uint32_t) readVarint32 -{ - uint32_t result = 0; - int shift = 0; - - while (true) { - uint8_t byte = [self readByte]; - result |= (uint32_t)(byte & 0x7f) << shift; - if (!(byte & 0x80)) { - break; - } - - shift += 7; - } - return result; -} - -- (uint64_t) readVarint64 -{ - int shift = 0; - uint64_t result = 0; - - while (true) { - uint8_t byte = [self readByte]; - result |= (uint64_t)(byte & 0x7f) << shift; - if (!(byte & 0x80)) { - break; - } - - shift += 7; - } - - return result; -} - -- (int32_t) zigZagToi32: (uint32_t) n -{ - return (int32_t)(n >> 1) ^ (-(int32_t)(n & 1)); -} - -- (int64_t) zigZagToi64: (uint64_t) n -{ - return (int64_t)(n >> 1) ^ (-(int64_t)(n & 1)); -} - -- (uint8_t) ttypeForCompactType: (uint8_t) type -{ - switch (type & 0x0f) { - case TCType_STOP: - return TType_STOP; - - case TCType_BOOLEAN_FALSE: - case TCType_BOOLEAN_TRUE: - return TType_BOOL; - - case TCType_BYTE: - return TType_BYTE; - - case TCType_I16: - return TType_I16; - - case TCType_I32: - return TType_I32; - - case TCType_I64: - return TType_I64; - - case TCType_DOUBLE: - return TType_DOUBLE; - - case TCType_BINARY: - return TType_STRING; - - case TCType_LIST: - return TType_LIST; - - case TCType_SET: - return TType_SET; - - case TCType_MAP: - return TType_MAP; - - case TCType_STRUCT: - return TType_STRUCT; - - default: - @throw [TProtocolException exceptionWithName: @"TProtocolException" - reason: [NSString stringWithFormat: @"Don't know what type: %d", (uint8_t)(type & 0x0F)]]; - } -} - -- (uint8_t) compactTypeForTType: (uint8_t) ttype -{ - static uint8_t ttypeToCompactType[] = { - [TType_STOP] = TCType_STOP, - [TType_BOOL] = TCType_BOOLEAN_FALSE, - [TType_BYTE] = TCType_BYTE, - [TType_DOUBLE] = TCType_DOUBLE, - [TType_I16] = TCType_I16, - [TType_I32] = TCType_I32, - [TType_I64] = TCType_I64, - [TType_STRING] = TCType_BINARY, - [TType_STRUCT] = TCType_STRUCT, - [TType_MAP] = TCType_MAP, - [TType_SET] = TCType_SET, - [TType_LIST] = TCType_LIST - }; - - return ttypeToCompactType[ttype]; -} - -@end
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.h deleted file mode 100644 index f298459..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> - -#import "TProtocolDecorator.h" - -FOUNDATION_EXPORT NSString *const MULTIPLEXED_SERVICE_SEPERATOR; - -@interface TMultiplexedProtocol : TProtocolDecorator { - NSString * mServiceName; -} - -- (id) initWithProtocol: (id <TProtocol>) protocol - serviceName: (NSString *) name; - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.m deleted file mode 100644 index 49095e3..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TMultiplexedProtocol.m +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TMultiplexedProtocol.h" - -#import "TProtocol.h" -#import "TObjective-C.h" - -NSString *const MULTIPLEXED_SERVICE_SEPERATOR = @":"; - -@implementation TMultiplexedProtocol - -- (id) initWithProtocol: (id <TProtocol>) protocol - serviceName: (NSString *) name -{ - self = [super initWithProtocol:protocol]; - - if (self) { - mServiceName = [name retain_stub]; - } - return self; -} - -- (void) writeMessageBeginWithName: (NSString *) name - type: (int) messageType - sequenceID: (int) sequenceID -{ - switch (messageType) { - case TMessageType_CALL: - case TMessageType_ONEWAY: - { - NSMutableString * serviceFunction = [[NSMutableString alloc] initWithString:mServiceName]; - [serviceFunction appendString:MULTIPLEXED_SERVICE_SEPERATOR]; - [serviceFunction appendString:name]; - [super writeMessageBeginWithName:serviceFunction type:messageType sequenceID:sequenceID]; - [serviceFunction release_stub]; - } - break; - default: - [super writeMessageBeginWithName:name type:messageType sequenceID:sequenceID]; - break; - } -} - -- (void) dealloc -{ - [mServiceName release_stub]; - [super dealloc_stub]; -} - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocol.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocol.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocol.h deleted file mode 100644 index 281239d..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocol.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> - -#import "TTransport.h" - - -enum { - TMessageType_CALL = 1, - TMessageType_REPLY = 2, - TMessageType_EXCEPTION = 3, - TMessageType_ONEWAY = 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 -}; - - -@protocol TProtocol <NSObject> - -- (id <TTransport>) transport; - -- (void) readMessageBeginReturningName: (NSString **) name - type: (int *) type - sequenceID: (int *) sequenceID; -- (void) readMessageEnd; - -- (void) readStructBeginReturningName: (NSString **) name; -- (void) readStructEnd; - -- (void) readFieldBeginReturningName: (NSString **) name - type: (int *) fieldType - fieldID: (int *) fieldID; -- (void) readFieldEnd; - -- (NSString *) readString; - -- (BOOL) readBool; - -- (unsigned char) readByte; - -- (short) readI16; - -- (int32_t) readI32; - -- (int64_t) readI64; - -- (double) readDouble; - -- (NSData *) readBinary; - -- (void) readMapBeginReturningKeyType: (int *) keyType - valueType: (int *) valueType - size: (int *) size; -- (void) readMapEnd; - - -- (void) readSetBeginReturningElementType: (int *) elementType - size: (int *) size; -- (void) readSetEnd; - - -- (void) readListBeginReturningElementType: (int *) elementType - size: (int *) size; -- (void) readListEnd; - - -- (void) writeMessageBeginWithName: (NSString *) name - type: (int) messageType - sequenceID: (int) sequenceID; -- (void) writeMessageEnd; - -- (void) writeStructBeginWithName: (NSString *) name; -- (void) writeStructEnd; - -- (void) writeFieldBeginWithName: (NSString *) name - type: (int) fieldType - fieldID: (int) fieldID; - -- (void) writeI32: (int32_t) value; - -- (void) writeI64: (int64_t) value; - -- (void) writeI16: (short) value; - -- (void) writeByte: (uint8_t) value; - -- (void) writeString: (NSString *) value; - -- (void) writeDouble: (double) value; - -- (void) writeBool: (BOOL) value; - -- (void) writeBinary: (NSData *) data; - -- (void) writeFieldStop; - -- (void) writeFieldEnd; - -- (void) writeMapBeginWithKeyType: (int) keyType - valueType: (int) valueType - size: (int) size; -- (void) writeMapEnd; - - -- (void) writeSetBeginWithElementType: (int) elementType - size: (int) size; -- (void) writeSetEnd; - - -- (void) writeListBeginWithElementType: (int) elementType - size: (int) size; - -- (void) writeListEnd; - - -@end - http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.h deleted file mode 100644 index 829bed6..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> - -#import "TProtocol.h" - -@interface TProtocolDecorator : NSObject <TProtocol> { - id<TProtocol> mConcreteProtocol; -} - -- (id) initWithProtocol: (id <TProtocol>) protocol; - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.m deleted file mode 100644 index e5acb6c..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolDecorator.m +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TProtocolDecorator.h" -#import "TObjective-C.h" - -@implementation TProtocolDecorator - -- (id) initWithProtocol: (id <TProtocol>) protocol -{ - self = [super init]; - if (self) { - mConcreteProtocol = [protocol retain_stub]; - } - return self; -} - -- (id <TTransport>) transport -{ - return [mConcreteProtocol transport]; -} - -- (void) readMessageBeginReturningName: (NSString **) name - type: (int *) type - sequenceID: (int *) sequenceID -{ - [mConcreteProtocol readMessageBeginReturningName:name - type:type - sequenceID:sequenceID]; -} - -- (void) readMessageEnd -{ - [mConcreteProtocol readMessageEnd]; -} - -- (void) readStructBeginReturningName: (NSString **) name -{ - [mConcreteProtocol readStructBeginReturningName:name]; -} - -- (void) readStructEnd -{ - [mConcreteProtocol readStructEnd]; -} - -- (void) readFieldBeginReturningName: (NSString **) name - type: (int *) fieldType - fieldID: (int *) fieldID -{ - [mConcreteProtocol readFieldBeginReturningName:name - type:fieldType - fieldID:fieldID]; -} -- (void) readFieldEnd -{ - [mConcreteProtocol readFieldEnd]; -} - -- (NSString *) readString -{ - return [mConcreteProtocol readString]; -} - -- (BOOL) readBool -{ - return [mConcreteProtocol readBool]; -} - -- (unsigned char) readByte -{ - return [mConcreteProtocol readByte]; -} - -- (short) readI16 -{ - return [mConcreteProtocol readI16]; -} - -- (int32_t) readI32 -{ - return [mConcreteProtocol readI32]; -} - -- (int64_t) readI64 -{ - return [mConcreteProtocol readI64]; -} - -- (double) readDouble -{ - return [mConcreteProtocol readDouble]; -} - -- (NSData *) readBinary -{ - return [mConcreteProtocol readBinary]; -} - -- (void) readMapBeginReturningKeyType: (int *) keyType - valueType: (int *) valueType - size: (int *) size -{ - [mConcreteProtocol readMapBeginReturningKeyType:keyType - valueType:valueType - size:size]; -} -- (void) readMapEnd -{ - [mConcreteProtocol readMapEnd]; -} - - -- (void) readSetBeginReturningElementType: (int *) elementType - size: (int *) size -{ - [mConcreteProtocol readSetBeginReturningElementType:elementType - size:size]; -} -- (void) readSetEnd -{ - [mConcreteProtocol readSetEnd]; -} - -- (void) readListBeginReturningElementType: (int *) elementType - size: (int *) size -{ - [mConcreteProtocol readListBeginReturningElementType:elementType - size:size]; -} -- (void) readListEnd -{ - [mConcreteProtocol readListEnd]; -} - -- (void) writeMessageBeginWithName: (NSString *) name - type: (int) messageType - sequenceID: (int) sequenceID -{ - [mConcreteProtocol writeMessageBeginWithName:name - type:messageType - sequenceID:sequenceID]; -} -- (void) writeMessageEnd -{ - [mConcreteProtocol writeMessageEnd]; -} - -- (void) writeStructBeginWithName: (NSString *) name -{ - [mConcreteProtocol writeStructBeginWithName:name]; -} -- (void) writeStructEnd -{ - [mConcreteProtocol writeStructEnd]; -} - -- (void) writeFieldBeginWithName: (NSString *) name - type: (int) fieldType - fieldID: (int) fieldID -{ - [mConcreteProtocol writeFieldBeginWithName:name - type:fieldType - fieldID:fieldID]; -} - -- (void) writeI32: (int32_t) value -{ - [mConcreteProtocol writeI32:value]; -} - -- (void) writeI64: (int64_t) value -{ - [mConcreteProtocol writeI64:value]; -} - -- (void) writeI16: (short) value -{ - [mConcreteProtocol writeI16:value]; -} - -- (void) writeByte: (uint8_t) value -{ - [mConcreteProtocol writeByte:value]; -} - -- (void) writeString: (NSString *) value -{ - [mConcreteProtocol writeString:value]; -} - -- (void) writeDouble: (double) value -{ - [mConcreteProtocol writeDouble:value]; -} - -- (void) writeBool: (BOOL) value -{ - [mConcreteProtocol writeBool:value]; -} - -- (void) writeBinary: (NSData *) data -{ - [mConcreteProtocol writeBinary:data]; -} - -- (void) writeFieldStop -{ - [mConcreteProtocol writeFieldStop]; -} - -- (void) writeFieldEnd -{ - [mConcreteProtocol writeFieldEnd]; -} - -- (void) writeMapBeginWithKeyType: (int) keyType - valueType: (int) valueType - size: (int) size -{ - [mConcreteProtocol writeMapBeginWithKeyType:keyType - valueType:valueType - size:size]; -} -- (void) writeMapEnd -{ - [mConcreteProtocol writeMapEnd]; -} - -- (void) writeSetBeginWithElementType: (int) elementType - size: (int) size -{ - [mConcreteProtocol writeSetBeginWithElementType:elementType size:size]; -} - -- (void) writeSetEnd -{ - [mConcreteProtocol writeSetEnd]; -} - -- (void) writeListBeginWithElementType: (int) elementType - size: (int) size -{ - [mConcreteProtocol writeListBeginWithElementType:elementType size:size]; -} - -- (void) writeListEnd -{ - [mConcreteProtocol writeListEnd]; -} - -- (void) dealloc -{ - [mConcreteProtocol release_stub]; - [super dealloc_stub]; -} - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.h deleted file mode 100644 index ad354fc..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TException.h" - -@interface TProtocolException : TException { -} - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.m deleted file mode 100644 index 681487a..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolException.m +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TProtocolException.h" - -@implementation TProtocolException -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolFactory.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolFactory.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolFactory.h deleted file mode 100644 index f200a6d..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolFactory.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> -#import "TProtocol.h" -#import "TTransport.h" - - -@protocol TProtocolFactory <NSObject> - -- (id <TProtocol>) newProtocolOnTransport: (id <TTransport>) transport; - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.h b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.h deleted file mode 100644 index 757748a..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TProtocol.h" -#import "TTransport.h" - -@interface TProtocolUtil : NSObject { - -} - -+ (void) skipType: (int) type onProtocol: (id <TProtocol>) protocol; - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.m b/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.m deleted file mode 100644 index 13d7095..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/protocol/TProtocolUtil.m +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TProtocolUtil.h" - -@implementation TProtocolUtil - -+ (void) skipType: (int) type onProtocol: (id <TProtocol>) protocol -{ - switch (type) { - case TType_BOOL: - [protocol readBool]; - break; - case TType_BYTE: - [protocol readByte]; - break; - case TType_I16: - [protocol readI16]; - break; - case TType_I32: - [protocol readI32]; - break; - case TType_I64: - [protocol readI64]; - break; - case TType_DOUBLE: - [protocol readDouble]; - break; - case TType_STRING: - [protocol readString]; - break; - case TType_STRUCT: - [protocol readStructBeginReturningName: NULL]; - while (true) { - int fieldType; - [protocol readFieldBeginReturningName: nil type: &fieldType fieldID: nil]; - if (fieldType == TType_STOP) { - break; - } - [TProtocolUtil skipType: fieldType onProtocol: protocol]; - [protocol readFieldEnd]; - } - [protocol readStructEnd]; - break; - case TType_MAP: - { - int keyType; - int valueType; - int size; - [protocol readMapBeginReturningKeyType: &keyType valueType: &valueType size: &size]; - int i; - for (i = 0; i < size; i++) { - [TProtocolUtil skipType: keyType onProtocol: protocol]; - [TProtocolUtil skipType: valueType onProtocol: protocol]; - } - [protocol readMapEnd]; - } - break; - case TType_SET: - { - int elemType; - int size; - [protocol readSetBeginReturningElementType: &elemType size: &size]; - int i; - for (i = 0; i < size; i++) { - [TProtocolUtil skipType: elemType onProtocol: protocol]; - } - [protocol readSetEnd]; - } - break; - case TType_LIST: - { - int elemType; - int size; - [protocol readListBeginReturningElementType: &elemType size: &size]; - int i; - for (i = 0; i < size; i++) { - [TProtocolUtil skipType: elemType onProtocol: protocol]; - } - [protocol readListEnd]; - } - break; - default: - return; - } -} - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/server/TSocketServer.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/server/TSocketServer.h b/depends/thirdparty/thrift/lib/cocoa/src/server/TSocketServer.h deleted file mode 100644 index c8ff9f0..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/server/TSocketServer.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> -#import "TProtocolFactory.h" -#import "TProcessorFactory.h" - -#if !TARGET_OS_IPHONE -#import <CoreServices/CoreServices.h> -#else -#import <CFNetwork/CFNetwork.h> -#endif - -extern NSString * const kTSocketServer_ClientConnectionFinishedForProcessorNotification; -extern NSString * const kTSocketServer_ProcessorKey; -extern NSString * const kTSockerServer_TransportKey; - - -@interface TSocketServer : NSObject { - NSFileHandle * mSocketFileHandle; - id <TProtocolFactory> mInputProtocolFactory; - id <TProtocolFactory> mOutputProtocolFactory; - id <TProcessorFactory> mProcessorFactory; -} - -- (id) initWithPort: (int) port - protocolFactory: (id <TProtocolFactory>) protocolFactory - processorFactory: (id <TProcessorFactory>) processorFactory; - -@end - - - http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/server/TSocketServer.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/server/TSocketServer.m b/depends/thirdparty/thrift/lib/cocoa/src/server/TSocketServer.m deleted file mode 100644 index 07bc829..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/server/TSocketServer.m +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> -#import "TSocketServer.h" -#import "TNSFileHandleTransport.h" -#import "TProtocol.h" -#import "TTransportException.h" -#import "TObjective-C.h" -#import <sys/socket.h> -#include <netinet/in.h> - - - -NSString * const kTSocketServer_ClientConnectionFinishedForProcessorNotification = @"TSocketServer_ClientConnectionFinishedForProcessorNotification"; -NSString * const kTSocketServer_ProcessorKey = @"TSocketServer_Processor"; -NSString * const kTSockerServer_TransportKey = @"TSockerServer_Transport"; - - -@implementation TSocketServer - -- (id) initWithPort: (int) port - protocolFactory: (id <TProtocolFactory>) protocolFactory - processorFactory: (id <TProcessorFactory>) processorFactory -{ - self = [super init]; - - mInputProtocolFactory = [protocolFactory retain_stub]; - mOutputProtocolFactory = [protocolFactory retain_stub]; - mProcessorFactory = [processorFactory retain_stub]; - - // create a socket. - int fd = -1; - CFSocketRef socket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_STREAM, IPPROTO_TCP, 0, NULL, NULL); - if (socket) { - CFOptionFlags flagsToClear = kCFSocketCloseOnInvalidate; - CFSocketSetSocketFlags(socket, CFSocketGetSocketFlags(socket) & ~flagsToClear); - - fd = CFSocketGetNative(socket); - int yes = 1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&yes, sizeof(yes)); - - struct sockaddr_in addr; - memset(&addr, 0, sizeof(addr)); - addr.sin_len = sizeof(addr); - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - addr.sin_addr.s_addr = htonl(INADDR_ANY); - NSData *address = [NSData dataWithBytes:&addr length:sizeof(addr)]; - if (CFSocketSetAddress(socket, (bridge_stub CFDataRef)address) != kCFSocketSuccess) { - CFSocketInvalidate(socket); - CFRelease(socket); - NSLog(@"*** Could not bind to address"); - return nil; - } - } else { - NSLog(@"*** No server socket"); - return nil; - } - - // wrap it in a file handle so we can get messages from it - mSocketFileHandle = [[NSFileHandle alloc] initWithFileDescriptor: fd - closeOnDealloc: YES]; - - // throw away our socket - CFSocketInvalidate(socket); - CFRelease(socket); - - // register for notifications of accepted incoming connections - [[NSNotificationCenter defaultCenter] addObserver: self - selector: @selector(connectionAccepted:) - name: NSFileHandleConnectionAcceptedNotification - object: mSocketFileHandle]; - - // tell socket to listen - [mSocketFileHandle acceptConnectionInBackgroundAndNotify]; - - NSLog(@"Listening on TCP port %d", port); - - return self; -} - - -- (void) dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - [mInputProtocolFactory release_stub]; - [mOutputProtocolFactory release_stub]; - [mProcessorFactory release_stub]; - [mSocketFileHandle release_stub]; - [super dealloc_stub]; -} - - -- (void) connectionAccepted: (NSNotification *) aNotification -{ - NSFileHandle * socket = [[aNotification userInfo] objectForKey: NSFileHandleNotificationFileHandleItem]; - - // now that we have a client connected, spin off a thread to handle activity - [NSThread detachNewThreadSelector: @selector(handleClientConnection:) - toTarget: self - withObject: socket]; - - [[aNotification object] acceptConnectionInBackgroundAndNotify]; -} - - -- (void) handleClientConnection: (NSFileHandle *) clientSocket -{ -#if __has_feature(objc_arc) - @autoreleasepool { - TNSFileHandleTransport * transport = [[TNSFileHandleTransport alloc] initWithFileHandle: clientSocket]; - id<TProcessor> processor = [mProcessorFactory processorForTransport: transport]; - - id <TProtocol> inProtocol = [mInputProtocolFactory newProtocolOnTransport: transport]; - id <TProtocol> outProtocol = [mOutputProtocolFactory newProtocolOnTransport: transport]; - - @try { - BOOL result = NO; - do { - @autoreleasepool { - result = [processor processOnInputProtocol: inProtocol outputProtocol: outProtocol]; - } - } while (result); - } - @catch (TTransportException * te) { - (void)te; - //NSLog(@"Caught transport exception, abandoning client connection: %@", te); - } - - NSNotification * n = [NSNotification notificationWithName: kTSocketServer_ClientConnectionFinishedForProcessorNotification - object: self - userInfo: [NSDictionary dictionaryWithObjectsAndKeys: - processor, - kTSocketServer_ProcessorKey, - transport, - kTSockerServer_TransportKey, - nil]]; - [[NSNotificationCenter defaultCenter] performSelectorOnMainThread: @selector(postNotification:) withObject: n waitUntilDone: YES]; - - } -#else - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - - TNSFileHandleTransport * transport = [[TNSFileHandleTransport alloc] initWithFileHandle: clientSocket]; - id<TProcessor> processor = [mProcessorFactory processorForTransport: transport]; - - id <TProtocol> inProtocol = [[mInputProtocolFactory newProtocolOnTransport: transport] autorelease]; - id <TProtocol> outProtocol = [[mOutputProtocolFactory newProtocolOnTransport: transport] autorelease]; - - @try { - BOOL result = NO; - do { - NSAutoreleasePool * myPool = [[NSAutoreleasePool alloc] init]; - result = [processor processOnInputProtocol: inProtocol outputProtocol: outProtocol]; - [myPool release]; - } while (result); - } - @catch (TTransportException * te) { - //NSLog(@"Caught transport exception, abandoning client connection: %@", te); - } - - NSNotification * n = [NSNotification notificationWithName: kTSocketServer_ClientConnectionFinishedForProcessorNotification - object: self - userInfo: [NSDictionary dictionaryWithObjectsAndKeys: - processor, - kTSocketServer_ProcessorKey, - transport, - kTSockerServer_TransportKey, - nil]]; - [[NSNotificationCenter defaultCenter] performSelectorOnMainThread: @selector(postNotification:) withObject: n waitUntilDone: YES]; - - [pool release]; -#endif -} - - - -@end - - - http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TAsyncTransport.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TAsyncTransport.h b/depends/thirdparty/thrift/lib/cocoa/src/transport/TAsyncTransport.h deleted file mode 100644 index f75b701..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TAsyncTransport.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TTransport.h" -#import "TException.h" - -typedef void(^TAsyncFailureBlock)(TException *); - -@protocol TAsyncTransport <TTransport> - -- (void) flush:(dispatch_block_t)flushed failure:(TAsyncFailureBlock)failure; - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TFramedTransport.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TFramedTransport.h b/depends/thirdparty/thrift/lib/cocoa/src/transport/TFramedTransport.h deleted file mode 100644 index fc38877..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TFramedTransport.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> -#import "TTransport.h" - -@interface TFramedTransport : NSObject <TTransport> { - id <TTransport> mTransport; -} - -- (id) initWithTransport: (id <TTransport>) transport; - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TFramedTransport.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TFramedTransport.m b/depends/thirdparty/thrift/lib/cocoa/src/transport/TFramedTransport.m deleted file mode 100644 index 2148806..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TFramedTransport.m +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TFramedTransport.h" -#import "TTransportException.h" -#import "TObjective-C.h" - -#define HEADER_SIZE 4 -#define INIT_FRAME_SIZE 1024 - -@implementation TFramedTransport { - NSMutableData* writeBuffer; - NSMutableData* readBuffer; - NSUInteger readOffset; - uint8_t dummy_header[HEADER_SIZE]; -} - -- (id) initWithTransport:(id <TTransport>)transport -{ - mTransport = [transport retain_stub]; - readBuffer = nil; - readOffset = 0; - writeBuffer = [[NSMutableData alloc] initWithCapacity:INIT_FRAME_SIZE]; - [writeBuffer appendBytes:dummy_header length:HEADER_SIZE]; - return self; -} - -- (void) dealloc -{ - [mTransport release_stub]; - [writeBuffer release_stub]; - if (readBuffer != nil) - [readBuffer release_stub]; - [super dealloc_stub]; -} - -- (void)flush -{ - size_t headerAndDataLength = [writeBuffer length]; - if (headerAndDataLength < HEADER_SIZE) { - @throw [TTransportException exceptionWithReason:@"Framed transport buffer has no header"]; - } - - size_t dataLength = headerAndDataLength - HEADER_SIZE; - uint8_t i32rd[HEADER_SIZE]; - i32rd[0] = (uint8_t)(0xff & (dataLength >> 24)); - i32rd[1] = (uint8_t)(0xff & (dataLength >> 16)); - i32rd[2] = (uint8_t)(0xff & (dataLength >> 8)); - i32rd[3] = (uint8_t)(0xff & (dataLength)); - - // should we make a copy of the writeBuffer instead? Better for threaded operations! - [writeBuffer replaceBytesInRange:NSMakeRange(0, HEADER_SIZE) withBytes:i32rd length:HEADER_SIZE]; - [mTransport write:[writeBuffer mutableBytes] offset:0 length:headerAndDataLength]; - [mTransport flush]; - - // reuse old memory buffer - [writeBuffer setLength:0]; - [writeBuffer appendBytes:dummy_header length:HEADER_SIZE]; -} - -- (void) write: (const uint8_t *) data offset: (size_t) offset length: (size_t) length -{ - [writeBuffer appendBytes:data+offset length:length]; -} - -- (size_t) readAll: (uint8_t *) buf offset: (size_t) offset length: (size_t) length -{ - if (readBuffer == nil) { - [self readFrame]; - } - - if (readBuffer != nil) { - size_t bufferLength = [readBuffer length]; - if (bufferLength - readOffset >= length) { - [readBuffer getBytes:buf range:NSMakeRange(readOffset,length)]; // copy data - readOffset += length; - } else { - // void the previous readBuffer data and request a new frame - [self readFrame]; - [readBuffer getBytes:buf range:NSMakeRange(0,length)]; // copy data - readOffset = length; - } - } - return length; -} - -- (void)readFrame -{ - uint8_t i32rd[HEADER_SIZE]; - [mTransport readAll: i32rd offset: 0 length: HEADER_SIZE]; - int32_t headerValue = - ((i32rd[0] & 0xff) << 24) | - ((i32rd[1] & 0xff) << 16) | - ((i32rd[2] & 0xff) << 8) | - ((i32rd[3] & 0xff)); - if (headerValue < 0) { - NSString *reason = [NSString stringWithFormat: - @"Frame header reports negative frame size: %"PRId32, - headerValue]; - @throw [TTransportException exceptionWithReason:reason]; - } - - /* Cast should be safe: - * Have verified headerValue non-negative and of lesser or equal bitwidth to size_t. */ - size_t frameSize = (size_t)headerValue; - [self ensureReadBufferHasLength:frameSize]; - - [mTransport readAll:[readBuffer mutableBytes] offset:0 length:frameSize]; -} - -- (void)ensureReadBufferHasLength:(size_t)length -{ - if (readBuffer == nil) { - readBuffer = [[NSMutableData alloc] initWithLength:length]; - } else { - size_t currentLength = [readBuffer length]; - BOOL isTooLong = (currentLength >= length); - if (isTooLong) { - [readBuffer setLength:length]; - } else { - size_t lengthToAdd = length - currentLength; - [readBuffer increaseLengthBy:lengthToAdd]; - } - } -} - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/THTTPClient.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/THTTPClient.h b/depends/thirdparty/thrift/lib/cocoa/src/transport/THTTPClient.h deleted file mode 100644 index 78935fb..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/THTTPClient.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> -#import "TTransport.h" - -@interface THTTPClient : NSObject <TTransport> { - NSURL * mURL; - NSMutableURLRequest * mRequest; - NSMutableData * mRequestData; - NSData * mResponseData; - size_t mResponseDataOffset; - NSString * mUserAgent; - int mTimeout; -} - -- (id) initWithURL: (NSURL *) aURL; - -- (id) initWithURL: (NSURL *) aURL - userAgent: (NSString *) userAgent - timeout: (int) timeout; - -- (void) setURL: (NSURL *) aURL; - -@end - http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/THTTPClient.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/THTTPClient.m b/depends/thirdparty/thrift/lib/cocoa/src/transport/THTTPClient.m deleted file mode 100644 index 169927c..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/THTTPClient.m +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "THTTPClient.h" -#import "TTransportException.h" -#import "TObjective-C.h" - -@implementation THTTPClient - - -- (void) setupRequest -{ - if (mRequest != nil) { - [mRequest release_stub]; - } - - // set up our request object that we'll use for each request - mRequest = [[NSMutableURLRequest alloc] initWithURL: mURL]; - [mRequest setHTTPMethod: @"POST"]; - [mRequest setValue: @"application/x-thrift" forHTTPHeaderField: @"Content-Type"]; - [mRequest setValue: @"application/x-thrift" forHTTPHeaderField: @"Accept"]; - - NSString * userAgent = mUserAgent; - if (!userAgent) { - userAgent = @"Cocoa/THTTPClient"; - } - [mRequest setValue: userAgent forHTTPHeaderField: @"User-Agent"]; - - [mRequest setCachePolicy: NSURLRequestReloadIgnoringCacheData]; - if (mTimeout) { - [mRequest setTimeoutInterval: mTimeout]; - } -} - - -- (id) initWithURL: (NSURL *) aURL -{ - return [self initWithURL: aURL - userAgent: nil - timeout: 0]; -} - - -- (id) initWithURL: (NSURL *) aURL - userAgent: (NSString *) userAgent - timeout: (int) timeout -{ - self = [super init]; - if (!self) { - return nil; - } - - mTimeout = timeout; - if (userAgent) { - mUserAgent = [userAgent retain_stub]; - } - mURL = [aURL retain_stub]; - - [self setupRequest]; - - // create our request data buffer - mRequestData = [[NSMutableData alloc] initWithCapacity: 1024]; - - return self; -} - - -- (void) setURL: (NSURL *) aURL -{ - [aURL retain_stub]; - [mURL release_stub]; - mURL = aURL; - - [self setupRequest]; -} - - -- (void) dealloc -{ - [mURL release_stub]; - [mUserAgent release_stub]; - [mRequest release_stub]; - [mRequestData release_stub]; - [mResponseData release_stub]; - [super dealloc_stub]; -} - - -- (size_t) readAll: (uint8_t *) buf offset: (size_t) offset length: (size_t) length -{ - NSRange r; - r.location = mResponseDataOffset; - r.length = length; - - [mResponseData getBytes: buf+offset range: r]; - mResponseDataOffset += length; - - return length; -} - - -- (void) write: (const uint8_t *) data offset: (size_t) offset length: (size_t) length -{ - [mRequestData appendBytes: data+offset length: length]; -} - - -- (void) flush -{ - [mRequest setHTTPBody: mRequestData]; // not sure if it copies the data - - // make the HTTP request - NSURLResponse * response; - NSError * error; - NSData * responseData = - [NSURLConnection sendSynchronousRequest: mRequest returningResponse: &response error: &error]; - - [mRequestData setLength: 0]; - - if (responseData == nil) { - @throw [TTransportException exceptionWithName: @"TTransportException" - reason: @"Could not make HTTP request" - error: error]; - } - if (![response isKindOfClass: [NSHTTPURLResponse class]]) { - @throw [TTransportException exceptionWithName: @"TTransportException" - reason: [NSString stringWithFormat: @"Unexpected NSURLResponse type: %@", - NSStringFromClass([response class])]]; - } - - NSHTTPURLResponse * httpResponse = (NSHTTPURLResponse *) response; - if ([httpResponse statusCode] != 200) { - @throw [TTransportException exceptionWithName: @"TTransportException" - reason: [NSString stringWithFormat: @"Bad response from HTTP server: %ld", - (long)[httpResponse statusCode]]]; - } - - // phew! - [mResponseData release_stub]; - mResponseData = [responseData retain_stub]; - mResponseDataOffset = 0; -} - - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TMemoryBuffer.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TMemoryBuffer.h b/depends/thirdparty/thrift/lib/cocoa/src/transport/TMemoryBuffer.h deleted file mode 100644 index fa4d371..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TMemoryBuffer.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> -#import "TTransport.h" - -@interface TMemoryBuffer : NSObject <TTransport> { - NSMutableData *mBuffer; - NSUInteger mOffset; -} -- (id)initWithData:(NSData *)data; -- (NSData *)getBuffer; -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TMemoryBuffer.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TMemoryBuffer.m b/depends/thirdparty/thrift/lib/cocoa/src/transport/TMemoryBuffer.m deleted file mode 100644 index 4513ab8..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TMemoryBuffer.m +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TMemoryBuffer.h" -#import "TTransportException.h" -#import "TObjective-C.h" - -#define GARBAGE_BUFFER_SIZE 4096 // 4KiB - -@implementation TMemoryBuffer -- (id)init { - if ((self = [super init])) { - mBuffer = [[NSMutableData alloc] init]; - mOffset = 0; - } - return self; -} - -- (id)initWithData:(NSData *)data { - if ((self = [super init])) { - mBuffer = [data mutableCopy]; - mOffset = 0; - } - return self; -} - -- (size_t) readAll: (uint8_t *) buf offset: (size_t) offset length: (size_t) length -{ - if ([mBuffer length] - mOffset < length) { - @throw [TTransportException exceptionWithReason:@"Not enough bytes remain in buffer"]; - } - [mBuffer getBytes:buf range:NSMakeRange(mOffset, length)]; - mOffset += length; - if (mOffset >= GARBAGE_BUFFER_SIZE) { - [mBuffer replaceBytesInRange:NSMakeRange(0, mOffset) withBytes:NULL length:0]; - mOffset = 0; - } - return length; -} - -- (void) write: (const uint8_t *) data offset: (size_t) offset length: (size_t) length -{ - [mBuffer appendBytes:data+offset length:length]; -} - -- (void)flush { - // noop -} - -- (NSData *)getBuffer { - return [[mBuffer copy] autorelease_stub]; -} - -- (void)dealloc { - [mBuffer release_stub]; - [super dealloc_stub]; -} -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.h b/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.h deleted file mode 100644 index ba2a209..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -#import <Foundation/Foundation.h> -#import "TTransport.h" - -@interface TNSFileHandleTransport : NSObject <TTransport> { - NSFileHandle * mInputFileHandle; - NSFileHandle * mOutputFileHandle; -} - -- (id) initWithFileHandle: (NSFileHandle *) fileHandle; - -- (id) initWithInputFileHandle: (NSFileHandle *) inputFileHandle - outputFileHandle: (NSFileHandle *) outputFileHandle; - - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.m b/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.m deleted file mode 100644 index c2b18ca..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.m +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -#import "TNSFileHandleTransport.h" -#import "TTransportException.h" -#import "TObjective-C.h" - - -@implementation TNSFileHandleTransport - -- (id) initWithFileHandle: (NSFileHandle *) fileHandle -{ - return [self initWithInputFileHandle: fileHandle - outputFileHandle: fileHandle]; -} - - -- (id) initWithInputFileHandle: (NSFileHandle *) inputFileHandle - outputFileHandle: (NSFileHandle *) outputFileHandle -{ - self = [super init]; - - mInputFileHandle = [inputFileHandle retain_stub]; - mOutputFileHandle = [outputFileHandle retain_stub]; - - return self; -} - - -- (void) dealloc { - [mInputFileHandle release_stub]; - [mOutputFileHandle release_stub]; - [super dealloc_stub]; -} - - -- (size_t) readAll: (uint8_t *) buf offset: (size_t) offset length: (size_t) length -{ - size_t totalBytesRead = 0; - while (totalBytesRead < length) { - NSData * data = [mInputFileHandle readDataOfLength: length-totalBytesRead]; - if ([data length] == 0) { - @throw [TTransportException exceptionWithName: @"TTransportException" - reason: @"Cannot read. No more data."]; - } - [data getBytes: buf+totalBytesRead]; - totalBytesRead += [data length]; - } - return totalBytesRead; -} - - -- (void) write: (const uint8_t *) data offset: (size_t) offset length: (size_t) length -{ - const void *pos = data + offset; - NSData * dataObject = [[NSData alloc] initWithBytesNoCopy: (void *)pos - length: length - freeWhenDone: NO]; - - @try { - [mOutputFileHandle writeData: dataObject]; - } @catch (NSException * e) { - @throw [TTransportException exceptionWithName: @"TTransportException" - reason: [NSString stringWithFormat: @"%s: Unable to write data: %@", __PRETTY_FUNCTION__, e]]; - } - - [dataObject release_stub]; -} - - -- (void) flush -{ - -} - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSStreamTransport.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSStreamTransport.h b/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSStreamTransport.h deleted file mode 100644 index 8011fb9..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSStreamTransport.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> -#import "TTransport.h" - -@interface TNSStreamTransport : NSObject <TTransport> { - -} - -@property (nonatomic, strong) NSInputStream * mInput; -@property (nonatomic, strong) NSOutputStream * mOutput; - -- (id) initWithInputStream: (NSInputStream *) input - outputStream: (NSOutputStream *) output; - -- (id) initWithInputStream: (NSInputStream *) input; - -- (id) initWithOutputStream: (NSOutputStream *) output; - -@end - - - http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSStreamTransport.m ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSStreamTransport.m b/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSStreamTransport.m deleted file mode 100644 index 7ac1cdc..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TNSStreamTransport.m +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import "TNSStreamTransport.h" -#import "TTransportException.h" -#import "TObjective-C.h" - - -@implementation TNSStreamTransport - -- (id) initWithInputStream: (NSInputStream *) input - outputStream: (NSOutputStream *) output -{ - self = [super init]; - self.mInput = [input retain_stub]; - self.mOutput = [output retain_stub]; - return self; -} - -- (id) initWithInputStream: (NSInputStream *) input -{ - return [self initWithInputStream: input outputStream: nil]; -} - -- (id) initWithOutputStream: (NSOutputStream *) output -{ - return [self initWithInputStream: nil outputStream: output]; -} - -- (void) dealloc -{ - [self.mInput release_stub]; - [self.mOutput release_stub]; - [super dealloc_stub]; -} - - -- (size_t) readAll: (uint8_t *) buf offset: (size_t) offset length: (size_t) length -{ - size_t totalBytesRead = 0; - ssize_t bytesRead = 0; - while (totalBytesRead < length) { - bytesRead = [self.mInput read: buf+offset+totalBytesRead maxLength: length-totalBytesRead]; - - BOOL encounteredErrorOrEOF = (bytesRead <= 0); - if (encounteredErrorOrEOF) { - @throw [TTransportException exceptionWithReason: @"Cannot read. Remote side has closed."]; - } else { - /* bytesRead is guaranteed to be positive and within the range representable by size_t. */ - totalBytesRead += (size_t)bytesRead; - } - } - return totalBytesRead; -} - - -- (void) write: (const uint8_t *) data offset: (size_t) offset length: (size_t) length -{ - size_t totalBytesWritten = 0; - ssize_t bytesWritten = 0; - while (totalBytesWritten < length) { - bytesWritten = [self.mOutput write: data+offset+totalBytesWritten maxLength: length-totalBytesWritten]; - if (bytesWritten < 0) { - @throw [TTransportException exceptionWithReason: @"Error writing to transport output stream." - error: [self.mOutput streamError]]; - } else if (bytesWritten == 0) { - @throw [TTransportException exceptionWithReason: @"End of output stream."]; - } else { - /* bytesWritten is guaranteed to be positive and within the range representable by size_t. */ - totalBytesWritten += (size_t)bytesWritten; - } - } -} - -- (void) flush -{ - // no flush for you! -} - -@end http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/928eade3/depends/thirdparty/thrift/lib/cocoa/src/transport/TSSLSocketClient.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/cocoa/src/transport/TSSLSocketClient.h b/depends/thirdparty/thrift/lib/cocoa/src/transport/TSSLSocketClient.h deleted file mode 100644 index 44de124..0000000 --- a/depends/thirdparty/thrift/lib/cocoa/src/transport/TSSLSocketClient.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#import <Foundation/Foundation.h> -#import "TNSStreamTransport.h" - -@interface TSSLSocketClient : TNSStreamTransport -#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) -<NSStreamDelegate> -#endif -{ - NSInputStream *inputStream; - NSOutputStream *outputStream; -@private - NSString *sslHostname; - int sd; -} - -- (id) initWithHostname: (NSString *) hostname - port: (int) port; - -- (BOOL) isOpen; - -@end
