(self, name, type, seqid)
| 156 | writeVarint(self.trans, n) |
| 157 | |
| 158 | def writeMessageBegin(self, name, type, seqid): |
| 159 | assert self.state == CLEAR |
| 160 | self.__writeUByte(self.PROTOCOL_ID) |
| 161 | self.__writeUByte(self.VERSION | (type << self.TYPE_SHIFT_AMOUNT)) |
| 162 | # The sequence id is a signed 32-bit integer but the compact protocol |
| 163 | # writes this out as a "var int" which is always positive, and attempting |
| 164 | # to write a negative number results in an infinite loop, so we may |
| 165 | # need to do some conversion here... |
| 166 | tseqid = seqid |
| 167 | if tseqid < 0: |
| 168 | tseqid = 2147483648 + (2147483648 + tseqid) |
| 169 | self.__writeVarint(tseqid) |
| 170 | self.__writeBinary(bytes(name, 'utf-8')) |
| 171 | self.state = VALUE_WRITE |
| 172 | |
| 173 | def writeMessageEnd(self): |
| 174 | assert self.state == VALUE_WRITE |
no test coverage detected