aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/protobuf/gen.nim3
-rw-r--r--src/protobuf/stream.nim14
2 files changed, 16 insertions, 1 deletions
diff --git a/src/protobuf/gen.nim b/src/protobuf/gen.nim
index 3e39fa4..4c943cb 100644
--- a/src/protobuf/gen.nim
+++ b/src/protobuf/gen.nim
@@ -328,7 +328,8 @@ proc generateReadMessageProc(desc: NimNode): NimNode =
`tagId` = readTag(`streamId`)
`wiretypeId` = getTagWireType(`tagId`)
case getTagFieldNumber(`tagId`)
- else: raise newException(Exception, "unknown field")
+ else:
+ skipField(`streamId`, `wiretypeId`)
let caseNode = body(result)[1][1][1]
diff --git a/src/protobuf/stream.nim b/src/protobuf/stream.nim
index b7e941d..83673a4 100644
--- a/src/protobuf/stream.nim
+++ b/src/protobuf/stream.nim
@@ -309,3 +309,17 @@ proc sizeOfSInt64*(value: int64): uint64 =
proc sizeOfEnum*[T](value: T): uint64 =
result = sizeOfUInt32(value.uint32)
+
+proc skipField*(stream: ProtobufStream, wiretype: WireType) =
+ case wiretype
+ of WireType.Varint:
+ discard readVarint(stream)
+ of WireType.Fixed64:
+ discard readFixed64(stream)
+ of WireType.Fixed32:
+ discard readFixed32(stream)
+ of WireType.LengthDelimited:
+ let size = readVarint(stream)
+ discard readStr(stream, int(size))
+ else:
+ raise newException(Exception, "unsupported wiretype: " & $wiretype)