blob: 126f5df91026db1af89dcca9dc362d51e00f0be3 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
Mark Slee7e9eea42007-09-10 21:00:23 +000020#import <Cocoa/Cocoa.h>
21
22#import "TTransport.h"
23
24
25enum {
26 TMessageType_CALL = 1,
27 TMessageType_REPLY = 2,
28 TMessageType_EXCEPTION = 3
29};
30
31enum {
32 TType_STOP = 0,
33 TType_VOID = 1,
34 TType_BOOL = 2,
35 TType_BYTE = 3,
36 TType_DOUBLE = 4,
37 TType_I16 = 6,
38 TType_I32 = 8,
39 TType_I64 = 10,
40 TType_STRING = 11,
41 TType_STRUCT = 12,
42 TType_MAP = 13,
43 TType_SET = 14,
44 TType_LIST = 15
45};
46
47
48@protocol TProtocol <NSObject>
49
50- (id <TTransport>) transport;
51
Mark Slee33a7d892007-09-14 19:44:30 +000052- (void) readMessageBeginReturningName: (NSString **) name
53 type: (int *) type
54 sequenceID: (int *) sequenceID;
Mark Slee7e9eea42007-09-10 21:00:23 +000055- (void) readMessageEnd;
56
Mark Slee33a7d892007-09-14 19:44:30 +000057- (void) readStructBeginReturningName: (NSString **) name;
Mark Slee7e9eea42007-09-10 21:00:23 +000058- (void) readStructEnd;
59
Mark Slee33a7d892007-09-14 19:44:30 +000060- (void) readFieldBeginReturningName: (NSString **) name
61 type: (int *) fieldType
62 fieldID: (int *) fieldID;
Mark Slee7e9eea42007-09-10 21:00:23 +000063- (void) readFieldEnd;
64
65- (NSString *) readString;
66
67- (BOOL) readBool;
68
69- (unsigned char) readByte;
70
71- (short) readI16;
72
73- (int32_t) readI32;
74
75- (int64_t) readI64;
76
77- (double) readDouble;
78
79- (NSData *) readBinary;
80
Mark Slee33a7d892007-09-14 19:44:30 +000081- (void) readMapBeginReturningKeyType: (int *) keyType
82 valueType: (int *) valueType
83 size: (int *) size;
Mark Slee7e9eea42007-09-10 21:00:23 +000084- (void) readMapEnd;
85
86
Mark Slee33a7d892007-09-14 19:44:30 +000087- (void) readSetBeginReturningElementType: (int *) elementType
88 size: (int *) size;
Mark Slee7e9eea42007-09-10 21:00:23 +000089- (void) readSetEnd;
90
91
Mark Slee33a7d892007-09-14 19:44:30 +000092- (void) readListBeginReturningElementType: (int *) elementType
93 size: (int *) size;
Mark Slee7e9eea42007-09-10 21:00:23 +000094- (void) readListEnd;
95
96
97- (void) writeMessageBeginWithName: (NSString *) name
98 type: (int) messageType
99 sequenceID: (int) sequenceID;
100- (void) writeMessageEnd;
101
102- (void) writeStructBeginWithName: (NSString *) name;
103- (void) writeStructEnd;
104
105- (void) writeFieldBeginWithName: (NSString *) name
106 type: (int) fieldType
107 fieldID: (int) fieldID;
108
109- (void) writeI32: (int32_t) value;
110
111- (void) writeI64: (int64_t) value;
112
113- (void) writeI16: (short) value;
114
115- (void) writeByte: (uint8_t) value;
116
117- (void) writeString: (NSString *) value;
118
119- (void) writeDouble: (double) value;
120
Mark Slee33a7d892007-09-14 19:44:30 +0000121- (void) writeBool: (BOOL) value;
122
Mark Slee7e9eea42007-09-10 21:00:23 +0000123- (void) writeBinary: (NSData *) data;
124
125- (void) writeFieldStop;
126
127- (void) writeFieldEnd;
128
129- (void) writeMapBeginWithKeyType: (int) keyType
130 valueType: (int) valueType
131 size: (int) size;
132- (void) writeMapEnd;
133
134
135- (void) writeSetBeginWithElementType: (int) elementType
136 size: (int) size;
137- (void) writeSetEnd;
138
139
140- (void) writeListBeginWithElementType: (int) elementType
141 size: (int) size;
142
143- (void) writeListEnd;
144
145
146@end
147