| 30 |
ashish |
1 |
/*
|
|
|
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 |
|
|
|
20 |
#import <Foundation/Foundation.h>
|
|
|
21 |
|
|
|
22 |
#import "TTransport.h"
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
enum {
|
|
|
26 |
TMessageType_CALL = 1,
|
|
|
27 |
TMessageType_REPLY = 2,
|
|
|
28 |
TMessageType_EXCEPTION = 3,
|
|
|
29 |
TMessageType_ONEWAY = 4
|
|
|
30 |
};
|
|
|
31 |
|
|
|
32 |
enum {
|
|
|
33 |
TType_STOP = 0,
|
|
|
34 |
TType_VOID = 1,
|
|
|
35 |
TType_BOOL = 2,
|
|
|
36 |
TType_BYTE = 3,
|
|
|
37 |
TType_DOUBLE = 4,
|
|
|
38 |
TType_I16 = 6,
|
|
|
39 |
TType_I32 = 8,
|
|
|
40 |
TType_I64 = 10,
|
|
|
41 |
TType_STRING = 11,
|
|
|
42 |
TType_STRUCT = 12,
|
|
|
43 |
TType_MAP = 13,
|
|
|
44 |
TType_SET = 14,
|
|
|
45 |
TType_LIST = 15
|
|
|
46 |
};
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
@protocol TProtocol <NSObject>
|
|
|
50 |
|
|
|
51 |
- (id <TTransport>) transport;
|
|
|
52 |
|
|
|
53 |
- (void) readMessageBeginReturningName: (NSString **) name
|
|
|
54 |
type: (int *) type
|
|
|
55 |
sequenceID: (int *) sequenceID;
|
|
|
56 |
- (void) readMessageEnd;
|
|
|
57 |
|
|
|
58 |
- (void) readStructBeginReturningName: (NSString **) name;
|
|
|
59 |
- (void) readStructEnd;
|
|
|
60 |
|
|
|
61 |
- (void) readFieldBeginReturningName: (NSString **) name
|
|
|
62 |
type: (int *) fieldType
|
|
|
63 |
fieldID: (int *) fieldID;
|
|
|
64 |
- (void) readFieldEnd;
|
|
|
65 |
|
|
|
66 |
- (NSString *) readString;
|
|
|
67 |
|
|
|
68 |
- (BOOL) readBool;
|
|
|
69 |
|
|
|
70 |
- (unsigned char) readByte;
|
|
|
71 |
|
|
|
72 |
- (short) readI16;
|
|
|
73 |
|
|
|
74 |
- (int32_t) readI32;
|
|
|
75 |
|
|
|
76 |
- (int64_t) readI64;
|
|
|
77 |
|
|
|
78 |
- (double) readDouble;
|
|
|
79 |
|
|
|
80 |
- (NSData *) readBinary;
|
|
|
81 |
|
|
|
82 |
- (void) readMapBeginReturningKeyType: (int *) keyType
|
|
|
83 |
valueType: (int *) valueType
|
|
|
84 |
size: (int *) size;
|
|
|
85 |
- (void) readMapEnd;
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
- (void) readSetBeginReturningElementType: (int *) elementType
|
|
|
89 |
size: (int *) size;
|
|
|
90 |
- (void) readSetEnd;
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
- (void) readListBeginReturningElementType: (int *) elementType
|
|
|
94 |
size: (int *) size;
|
|
|
95 |
- (void) readListEnd;
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
- (void) writeMessageBeginWithName: (NSString *) name
|
|
|
99 |
type: (int) messageType
|
|
|
100 |
sequenceID: (int) sequenceID;
|
|
|
101 |
- (void) writeMessageEnd;
|
|
|
102 |
|
|
|
103 |
- (void) writeStructBeginWithName: (NSString *) name;
|
|
|
104 |
- (void) writeStructEnd;
|
|
|
105 |
|
|
|
106 |
- (void) writeFieldBeginWithName: (NSString *) name
|
|
|
107 |
type: (int) fieldType
|
|
|
108 |
fieldID: (int) fieldID;
|
|
|
109 |
|
|
|
110 |
- (void) writeI32: (int32_t) value;
|
|
|
111 |
|
|
|
112 |
- (void) writeI64: (int64_t) value;
|
|
|
113 |
|
|
|
114 |
- (void) writeI16: (short) value;
|
|
|
115 |
|
|
|
116 |
- (void) writeByte: (uint8_t) value;
|
|
|
117 |
|
|
|
118 |
- (void) writeString: (NSString *) value;
|
|
|
119 |
|
|
|
120 |
- (void) writeDouble: (double) value;
|
|
|
121 |
|
|
|
122 |
- (void) writeBool: (BOOL) value;
|
|
|
123 |
|
|
|
124 |
- (void) writeBinary: (NSData *) data;
|
|
|
125 |
|
|
|
126 |
- (void) writeFieldStop;
|
|
|
127 |
|
|
|
128 |
- (void) writeFieldEnd;
|
|
|
129 |
|
|
|
130 |
- (void) writeMapBeginWithKeyType: (int) keyType
|
|
|
131 |
valueType: (int) valueType
|
|
|
132 |
size: (int) size;
|
|
|
133 |
- (void) writeMapEnd;
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
- (void) writeSetBeginWithElementType: (int) elementType
|
|
|
137 |
size: (int) size;
|
|
|
138 |
- (void) writeSetEnd;
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
- (void) writeListBeginWithElementType: (int) elementType
|
|
|
142 |
size: (int) size;
|
|
|
143 |
|
|
|
144 |
- (void) writeListEnd;
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
@end
|
|
|
148 |
|