Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame^] | 1 | class TType: |
| 2 | STOP = 0 |
| 3 | VOID = 1 |
| 4 | BOOL = 2 |
| 5 | BYTE = 3 |
| 6 | I08 = 4 |
| 7 | I16 = 6 |
| 8 | I32 = 8 |
| 9 | I64 = 10 |
| 10 | STRING = 11 |
| 11 | UTF7 = 11 |
| 12 | STRUCT = 12 |
| 13 | MAP = 13 |
| 14 | SET = 14 |
| 15 | LIST = 15 |
| 16 | UTF8 = 16 |
| 17 | UTF16 = 17 |
| 18 | |
| 19 | class TMessageType: |
| 20 | CALL = 1 |
| 21 | REPLY = 2 |
| 22 | |
| 23 | class TProtocolBase: |
| 24 | |
| 25 | """Base class for Thrift protocol driver.""" |
| 26 | |
| 27 | def writeMessageBegin(self, otrans, name, type, seqid): |
| 28 | pass |
| 29 | |
| 30 | def writeMessageEnd(self, otrans): |
| 31 | pass |
| 32 | |
| 33 | def writeStructBegin(self, otrans, name): |
| 34 | pass |
| 35 | |
| 36 | def writeStructEnd(self, otrans): |
| 37 | pass |
| 38 | |
| 39 | def writeFieldBegin(self, otrans, name, type, id): |
| 40 | pass |
| 41 | |
| 42 | def writeFieldEnd(self, otrans): |
| 43 | pass |
| 44 | |
| 45 | def writeFieldStop(self, otrans): |
| 46 | pass |
| 47 | |
| 48 | def writeMapBegin(self, otrans, ktype, vtype, size): |
| 49 | pass |
| 50 | |
| 51 | def writeMapEnd(self, otrans): |
| 52 | pass |
| 53 | |
| 54 | def writeListBegin(self, otrans, etype, size): |
| 55 | pass |
| 56 | |
| 57 | def writeListEnd(self, otrans): |
| 58 | pass |
| 59 | |
| 60 | def writeSetBegin(self, otrans, etype, size): |
| 61 | pass |
| 62 | |
| 63 | def writeSetEnd(self, otrans): |
| 64 | pass |
| 65 | |
| 66 | def writeBool(self, otrans, bool): |
| 67 | pass |
| 68 | |
| 69 | def writeByte(self, otrans, byte): |
| 70 | pass |
| 71 | |
| 72 | def writeI16(self, otrans, i16): |
| 73 | pass |
| 74 | |
| 75 | def writeI32(self, otrans, i32): |
| 76 | pass |
| 77 | |
| 78 | def writeI64(self, otrans, i64): |
| 79 | pass |
| 80 | |
| 81 | def writeString(self, otrans, str): |
| 82 | pass |
| 83 | |
| 84 | def readMessageBegin(self, itrans): |
| 85 | pass |
| 86 | |
| 87 | def readMessageEnd(self, itrans): |
| 88 | pass |
| 89 | |
| 90 | def readStructBegin(self, itrans): |
| 91 | pass |
| 92 | |
| 93 | def readStructEnd(self, itrans): |
| 94 | pass |
| 95 | |
| 96 | def readFieldBegin(self, itrans): |
| 97 | pass |
| 98 | |
| 99 | def readFieldEnd(self, itrans): |
| 100 | pass |
| 101 | |
| 102 | def readMapBegin(self, itrans): |
| 103 | pass |
| 104 | |
| 105 | def readMapEnd(self, itrans): |
| 106 | pass |
| 107 | |
| 108 | def readListBegin(self, itrans): |
| 109 | pass |
| 110 | |
| 111 | def readListEnd(self, itrans): |
| 112 | pass |
| 113 | |
| 114 | def readSetBegin(self, itrans): |
| 115 | pass |
| 116 | |
| 117 | def readSetEnd(self, itrans): |
| 118 | pass |
| 119 | |
| 120 | def readBool(self, itrans): |
| 121 | pass |
| 122 | |
| 123 | def readByte(self, itrans): |
| 124 | pass |
| 125 | |
| 126 | def readI16(self, itrans): |
| 127 | pass |
| 128 | |
| 129 | def readI32(self, itrans): |
| 130 | pass |
| 131 | |
| 132 | def readI64(self, itrans): |
| 133 | pass |
| 134 | |
| 135 | def readString(self, itrans): |
| 136 | pass |
| 137 | |
| 138 | def skip(self, itrans, type): |
| 139 | if type == TType.STOP: |
| 140 | return |
| 141 | elif type == TType.BOOL: |
| 142 | self.readBool(itrans) |
| 143 | elif type == TType.BYTE: |
| 144 | self.readByte(itrans) |
| 145 | elif type == TType.I16: |
| 146 | self.readI16(itrans) |
| 147 | elif type == TType.I32: |
| 148 | self.readI32(itrans) |
| 149 | elif type == TType.I64: |
| 150 | self.readI64(itrans) |
| 151 | elif type == TType.STRING: |
| 152 | self.readString(itrans) |
| 153 | elif type == TType.STRUCT: |
| 154 | name = self.readStructBegin(itrans) |
| 155 | while True: |
| 156 | (name, type, id) = self.readFieldBegin(itrans) |
| 157 | if type == TType.STOP: |
| 158 | break |
| 159 | self.skip(itrans, type) |
| 160 | self.readFieldEnd(itrans) |
| 161 | self.readStructEnd(itrans) |
| 162 | elif type == TType.MAP: |
| 163 | (ktype, vtype, size) = self.readMapBegin(itrans) |
| 164 | for i in range(size): |
| 165 | self.skip(itrans, ktype) |
| 166 | self.skip(itrans, vtype) |
| 167 | self.readMapEnd(itrans) |
| 168 | elif type == TType.SET: |
| 169 | (etype, size) = self.readSetBegin(itrans) |
| 170 | for i in range(size): |
| 171 | self.skip(itrans, etype) |
| 172 | self.readSetEnd(itrans) |
| 173 | elif type == TType.LIST: |
| 174 | (etype, size) = self.readListBegin(itrans) |
| 175 | for i in range(size): |
| 176 | self.skip(itrans, etype) |
| 177 | self.readListEnd(itrans) |
| 178 | |
| 179 | |
| 180 | |