equal
deleted
inserted
replaced
342 return |
342 return |
343 |
343 |
344 |
344 |
345 def putFloat(self, v): |
345 def putFloat(self, v): |
346 a = array.array('B') |
346 a = array.array('B') |
347 a.fromstring(struct.pack("f", v)) |
347 a.fromstring(struct.pack("<f", v)) |
348 self.buf.extend(a) |
348 self.buf.extend(a) |
349 return |
349 return |
350 |
350 |
351 def putDouble(self, v): |
351 def putDouble(self, v): |
352 a = array.array('B') |
352 a = array.array('B') |
353 a.fromstring(struct.pack("d", v)) |
353 a.fromstring(struct.pack("<d", v)) |
354 self.buf.extend(a) |
354 self.buf.extend(a) |
355 return |
355 return |
356 |
356 |
357 def putBoolean(self, v): |
357 def putBoolean(self, v): |
358 if v: |
358 if v: |
360 else: |
360 else: |
361 self.buf.append(0) |
361 self.buf.append(0) |
362 return |
362 return |
363 |
363 |
364 def putPrefixedString(self, v): |
364 def putPrefixedString(self, v): |
|
365 v = str(v) |
365 self.putVarInt32(len(v)) |
366 self.putVarInt32(len(v)) |
366 self.buf.fromstring(v) |
367 self.buf.fromstring(v) |
367 return |
368 return |
368 |
369 |
369 def putRawString(self, v): |
370 def putRawString(self, v): |
497 |
498 |
498 def getFloat(self): |
499 def getFloat(self): |
499 if self.idx + 4 > self.limit: raise ProtocolBufferDecodeError, "truncated" |
500 if self.idx + 4 > self.limit: raise ProtocolBufferDecodeError, "truncated" |
500 a = self.buf[self.idx:self.idx+4] |
501 a = self.buf[self.idx:self.idx+4] |
501 self.idx += 4 |
502 self.idx += 4 |
502 return struct.unpack("f", a)[0] |
503 return struct.unpack("<f", a)[0] |
503 |
504 |
504 def getDouble(self): |
505 def getDouble(self): |
505 if self.idx + 8 > self.limit: raise ProtocolBufferDecodeError, "truncated" |
506 if self.idx + 8 > self.limit: raise ProtocolBufferDecodeError, "truncated" |
506 a = self.buf[self.idx:self.idx+8] |
507 a = self.buf[self.idx:self.idx+8] |
507 self.idx += 8 |
508 self.idx += 8 |
508 return struct.unpack("d", a)[0] |
509 return struct.unpack("<d", a)[0] |
509 |
510 |
510 def getBoolean(self): |
511 def getBoolean(self): |
511 b = self.get8() |
512 b = self.get8() |
512 if b != 0 and b != 1: raise ProtocolBufferDecodeError, "corrupted" |
513 if b != 0 and b != 1: raise ProtocolBufferDecodeError, "corrupted" |
513 return b |
514 return b |