Skip to content

Commit

Permalink
Merge pull request #6 from JordanGoulder/master
Browse files Browse the repository at this point in the history
Add bool type support, Fixes #5
  • Loading branch information
mildsunrise authored Apr 29, 2020
2 parents d67c6ac + 0082760 commit 117fd01
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self):
self.groups_observed = False

types_to_register = {
0: ["varint", "sint32", "sint64", "int32", "int64", "uint32", "uint64", "enum"],
0: ["varint", "sint32", "sint64", "int32", "int64", "uint32", "uint64", "enum", "bool"],
1: ["64bit", "sfixed64", "fixed64", "double"],
2: ["chunk", "bytes", "string", "message", "packed", "dump"],
5: ["32bit", "sfixed32", "fixed32", "float"],
Expand Down Expand Up @@ -181,6 +181,10 @@ def parse_uint64(self, x, type):
assert(0 <= x < (1 << 64))
return fg3(str(x))

def parse_bool(self, x, type):
assert(0 <= x < (1 << 1))
return fg3(str(bool(x)))

def parse_string(self, file, type):
string = file.read().decode("utf-8")
return fg2('"%s"' % (repr(string)[1:-1]))
Expand Down

0 comments on commit 117fd01

Please sign in to comment.