aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nimpb/compiler/generator.nim21
-rw-r--r--nimpb/nimpb.nim8
-rw-r--r--nimpb/wkt/any.nim292
-rw-r--r--nimpb/wkt/any_pb.nim10
-rw-r--r--nimpb/wkt/api_pb.nim42
-rw-r--r--nimpb/wkt/descriptor_pb.nim270
-rw-r--r--nimpb/wkt/duration.nim3
-rw-r--r--nimpb/wkt/duration_pb.nim10
-rw-r--r--nimpb/wkt/empty_pb.nim14
-rw-r--r--nimpb/wkt/field_mask.nim3
-rw-r--r--nimpb/wkt/field_mask_pb.nim10
-rw-r--r--nimpb/wkt/source_context_pb.nim14
-rw-r--r--nimpb/wkt/struct.nim6
-rw-r--r--nimpb/wkt/struct_pb.nim30
-rw-r--r--nimpb/wkt/timestamp.nim3
-rw-r--r--nimpb/wkt/timestamp_pb.nim10
-rw-r--r--nimpb/wkt/type_pb.nim70
-rw-r--r--nimpb/wkt/utils.nim11
-rw-r--r--nimpb/wkt/wrappers.nim11
-rw-r--r--nimpb/wkt/wrappers_pb.nim90
-rw-r--r--tests/conformance/conformance_nim.nim3
21 files changed, 897 insertions, 34 deletions
diff --git a/nimpb/compiler/generator.nim b/nimpb/compiler/generator.nim
index 83ef893..7590bde 100644
--- a/nimpb/compiler/generator.nim
+++ b/nimpb/compiler/generator.nim
@@ -685,6 +685,7 @@ iterator genNewMessageProc(msg: Message): string =
yield &"proc new{msg.names}*(): {msg.names} ="
yield indent("new(result)", 4)
yield indent("initMessage(result[])", 4)
+ yield indent(&"result.procs = {msg.names}Procs()", 4)
for field in msg.fields:
if field.oneof == nil:
yield indent(&"result.{field.accessor} = {defaultValue(field)}", 4)
@@ -1125,12 +1126,32 @@ iterator genMessageProcForwards(msg: Message): string =
yield &"proc read{msg.names}KV(stream: Stream, tbl: TableRef[{key.fullType}, {value.fullType}])"
yield &"proc sizeOf{msg.names}KV(key: {key.fullType}, value: {value.fullType}): uint64"
+iterator genMessageProcImpls(msg: Message): string =
+ yield &"proc read{msg.names}Impl(stream: Stream): Message = read{msg.names}(stream)"
+ yield &"proc write{msg.names}Impl(stream: Stream, msg: Message) = write{msg.names}(stream, {msg.names}(msg))"
+ if msg.file.syntax == Syntax.Proto3 and shouldGenerateJsonProcs($msg.names):
+ yield &"proc toJson{msg.names}Impl(msg: Message): JsonNode = toJson({msg.names}(msg))"
+ yield &"proc fromJson{msg.names}Impl(node: JsonNode): Message = parse{msg.names}(node)"
+ yield ""
+ yield &"proc {msg.names}Procs*(): MessageProcs ="
+ yield &" result.readImpl = read{msg.names}Impl"
+ yield &" result.writeImpl = write{msg.names}Impl"
+ if msg.file.syntax == Syntax.Proto3 and shouldGenerateJsonProcs($msg.names):
+ yield &" result.toJsonImpl = toJson{msg.names}Impl"
+ yield &" result.fromJsonImpl = fromJson{msg.names}Impl"
+ yield ""
+
iterator genProcs(msg: Message): string =
if isMapEntry(msg):
for line in genSizeOfMapKVProc(msg): yield line
for line in genWriteMapKVProc(msg): yield line
for line in genReadMapKVProc(msg): yield line
else:
+ yield &"proc fullyQualifiedName*(T: typedesc[{msg.names}]): string = \"{join(seq[string](msg.names), \".\")}\""
+ yield ""
+
+ for line in genMessageProcImpls(msg): yield line
+
for line in genNewMessageProc(msg): yield line
for field in msg.fields:
diff --git a/nimpb/nimpb.nim b/nimpb/nimpb.nim
index f00bc87..228ac35 100644
--- a/nimpb/nimpb.nim
+++ b/nimpb/nimpb.nim
@@ -1,5 +1,6 @@
import endians
import intsets
+import std/json
import macros
import streams
import strutils
@@ -67,6 +68,13 @@ type
MessageObj* = object of RootObj
hasField: IntSet
unknownFields: seq[UnknownField]
+ procs*: MessageProcs
+
+ MessageProcs* = object
+ readImpl*: proc (stream: Stream): Message
+ writeImpl*: proc (stream: Stream, msg: Message)
+ toJsonImpl*: proc (msg: Message): JsonNode
+ fromJsonImpl*: proc (node: JsonNode): Message
proc wiretype*(ft: FieldType): WireType =
case ft
diff --git a/nimpb/wkt/any.nim b/nimpb/wkt/any.nim
index 6cf40a7..768a8d4 100644
--- a/nimpb/wkt/any.nim
+++ b/nimpb/wkt/any.nim
@@ -1,52 +1,276 @@
import json
+import tables
import duration
+import empty_pb
import field_mask
import struct
import timestamp
+import wrappers
include any_pb
+import utils
-proc toJson*(message: google_protobuf_Any): JsonNode =
- case message.typeUrl
- of "type.googleapis.com/google.protobuf.Duration":
- let duration = newGoogleProtobufDuration(message.value)
- result = newJObject()
- result["@type"] = %message.typeUrl
+var
+ typeRegistry = newTable[string, MessageProcs]()
+
+proc registerType*(prefix, typeName: string, procs: MessageProcs) =
+ ## Register message procs to the type registry.
+ ##
+ ## The type registry associates a type url with message procs. The type url
+ ## is constructed from the prefix and typeName by joining them with a
+ ## forward slash.
+ typeRegistry[prefix & "/" & typeName] = procs
+
+template registerType*(T: typedesc) =
+ ## Register a type to the type registry.
+ ##
+ ## This is a convenience template around the registerType() proc. The prefix
+ ## used is "type.googleapis.com".
+ var procs = `T Procs`()
+ registerType("type.googleapis.com", fullyQualifiedName(T), procs)
+
+template registerType*(prefix: string, T: typedesc) =
+ ## Register a type to the type registry with a custom prefix.
+ var procs = `T Procs`()
+ registerType(prefix, fullyQualifiedName(T), procs)
+
+template pack*(msg: typed): google_protobuf_Any =
+ ## Pack a message into an Any.
+ var
+ any = newgoogle_protobuf_Any()
+ any.typeUrl = "type.googleapis.com/" & fullyQualifiedName(type(msg))
+ any.value = cast[seq[byte]](serialize(msg))
+ any
+
+template pack*(msg: typed, prefix: string): google_protobuf_Any =
+ ## Pack a message into an Any with a custom prefix.
+ var
+ any = newgoogle_protobuf_Any()
+ any.typeUrl = prefix & "/" & fullyQualifiedName(type(msg))
+ any.value = cast[seq[byte]](serialize(msg))
+ any
+
+proc unpack*(src: google_protobuf_Any): Message =
+ ## Unpack an Any into a message based on the typeUrl of the Any.
+ ##
+ ## The typeUrl must exist in the type registry.
+ if src.typeUrl notin typeRegistry:
+ raise newException(KeyError, "unknown type url: " & src.typeUrl)
+
+ let
+ procs = typeRegistry[src.typeUrl]
+ ss = newStringStream(cast[string](src.value))
+
+ result = procs.readImpl(ss)
+
+proc getTypenameFromTypeUrl*(typeUrl: string): string =
+ ## Extract the type name from a type url.
+ ##
+ ## Returns the last slash delimited part of the type url.
+ let slashIndex = rfind(typeUrl, '/')
+ if slashIndex != -1:
+ result = typeUrl[slashIndex+1..^1]
+ else:
+ result = typeUrl
+
+proc toJson*(msg: google_protobuf_Any): JsonNode =
+ ## Convert an Any into JSON.
+ ##
+ ## If the embedded message is a well known type, the conversion should
+ ## succeed if the values in the message are valid.
+ ##
+ ## Otherwise, the type url of the embedded message has to be registered in
+ ## the type registry, so that this procs knows how to convert the embedded
+ ## message into JSON.
+ result = newJObject()
+ result["@type"] = %msg.typeUrl
+
+ let typeName = getTypenameFromTypeUrl(msg.typeUrl)
+
+ case typeName
+ of "google.protobuf.Duration":
+ let duration = newgoogle_protobuf_Duration(cast[string](msg.value))
result["value"] = toJson(duration)
- of "type.googleapis.com/google.protobuf.Empty":
- result = newJObject()
- result["@type"] = %message.typeUrl
+ of "google.protobuf.Empty":
result["value"] = newJObject()
- of "type.googleapis.com/google.protobuf.FieldMask":
- let mask = newGoogleProtobufFieldMask(message.value)
- result = newJObject()
- result["@type"] = %message.typeUrl
+ of "google.protobuf.FieldMask":
+ let mask = newgoogle_protobuf_FieldMask(cast[string](msg.value))
result["value"] = toJson(mask)
- of "type.googleapis.com/google.protobuf.Struct":
- let struct = newGoogleProtobufStruct(message.value)
- result = newJObject()
- result["@type"] = %message.typeUrl
+ of "google.protobuf.Struct":
+ let struct = newgoogle_protobuf_Struct(cast[string](msg.value))
result["value"] = toJson(struct)
- of "type.googleapis.com/google.protobuf.Value":
- let value = newGoogleProtobufValue(message.value)
- result = newJObject()
- result["@type"] = %message.typeUrl
- result["value"] = toJson(value)
- of "type.googleapis.com/google.protobuf.ListValue":
- let lst = newGoogleProtobufListValue(message.value)
- result = newJObject()
- result["@type"] = %message.typeUrl
+ of "google.protobuf.Value":
+ let value = newgoogle_protobuf_Value(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.ListValue":
+ let lst = newgoogle_protobuf_ListValue(cast[string](msg.value))
result["value"] = toJson(lst)
- of "type.googleapis.com/google.protobuf.Timestamp":
- let value = newGoogleProtobufTimestamp(message.value)
- result = newJObject()
- result["@type"] = %message.typeUrl
+ of "google.protobuf.Timestamp":
+ let value = newgoogle_protobuf_Timestamp(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.DoubleValue":
+ let value = newgoogle_protobuf_DoubleValue(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.FloatValue":
+ let value = newgoogle_protobuf_FloatValue(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.Int64Value":
+ let value = newgoogle_protobuf_Int64Value(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.UInt64Value":
+ let value = newgoogle_protobuf_UInt64Value(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.Int32Value":
+ let value = newgoogle_protobuf_Int32Value(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.UInt32Value":
+ let value = newgoogle_protobuf_UInt32Value(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.BoolValue":
+ let value = newgoogle_protobuf_BoolValue(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.StringValue":
+ let value = newgoogle_protobuf_StringValue(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.BytesValue":
+ let value = newgoogle_protobuf_BytesValue(cast[string](msg.value))
+ result["value"] = toJson(value)
+ of "google.protobuf.Any":
+ let value = newgoogle_protobuf_Any(cast[string](msg.value))
result["value"] = toJson(value)
else:
- result = newJObject()
- result["typeUrl"] = %message.typeUrl
- result["value"] = %message.value
+ if msg.typeUrl notin typeRegistry:
+ raise newException(nimpb_json.ParseError,
+ "unknown type url: " & msg.typeUrl)
+
+ let
+ procs = typeRegistry[msg.typeUrl]
+ ss = newStringStream(cast[string](msg.value))
+ submsg = procs.readImpl(ss)
+ node = procs.toJsonImpl(submsg)
+
+ for k, v in node:
+ result[k] = v
proc parsegoogle_protobuf_Any*(node: JsonNode): google_protobuf_Any =
- raise newException(nimpb_json.ParseError, "not supported yet")
+ ## Convert JSON into an Any.
+ ##
+ ## If the JSON represents a well known type, the conversion should succeed
+ ## if the JSON is valid and represents a valid message.
+ ##
+ ## Otherwise, the type url of the embedded message needs to be registered
+ ## in the type registry, so that this procs knows how to convert the JSON
+ ## into a correct message.
+ if node.kind != JObject:
+ raise newException(nimpb_json.ParseError, "object expected")
+
+ if "@type" notin node:
+ raise newException(nimpb_json.ParseError, "@type not present")
+
+ if node["@type"].kind != JString:
+ raise newException(nimpb_json.ParseError,
+ "@type is not a string (it's " & $node["@type"].kind & ")")
+
+ let typeUrl = node["@type"].str
+ let typeName = getTypenameFromTypeUrl(typeUrl)
+
+ var
+ subMessageData: string
+
+ case typeName
+ of "google.protobuf.Duration":
+ let submsg = parsegoogle_protobuf_Duration(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.FieldMask":
+ let submsg = parsegoogle_protobuf_FieldMask(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.Struct":
+ let submsg = parsegoogle_protobuf_Struct(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.Value":
+ let submsg = parsegoogle_protobuf_Value(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.ListValue":
+ let submsg = parsegoogle_protobuf_ListValue(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.NullValue":
+ # TODO: ?
+ # let submsg = parsegoogle_protobuf_NullValue(node["value"])
+ # subMessageData = serialize(submsg)
+ discard
+ of "google.protobuf.Timestamp":
+ let submsg = parsegoogle_protobuf_Timestamp(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.DoubleValue":
+ let submsg = parsegoogle_protobuf_DoubleValue(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.FloatValue":
+ let submsg = parsegoogle_protobuf_FloatValue(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.Int64Value":
+ let submsg = parsegoogle_protobuf_Int64Value(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.UInt64Value":
+ let submsg = parsegoogle_protobuf_UInt64Value(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.Int32Value":
+ let submsg = parsegoogle_protobuf_Int32Value(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.UInt32Value":
+ let submsg = parsegoogle_protobuf_UInt32Value(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.BoolValue":
+ let submsg = parsegoogle_protobuf_BoolValue(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.StringValue":
+ let submsg = parsegoogle_protobuf_StringValue(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.BytesValue":
+ let submsg = parsegoogle_protobuf_BytesValue(node["value"])
+ subMessageData = serialize(submsg)
+ of "google.protobuf.Any":
+ let submsg = parsegoogle_protobuf_Any(node["value"])
+ subMessageData = serialize(submsg)
+ else:
+ if typeUrl notin typeRegistry:
+ raise newException(nimpb_json.ParseError,
+ "unknown type url: " & typeUrl)
+
+ let
+ procs = typeRegistry[typeUrl]
+ submsg = procs.fromJsonImpl(node)
+ ss = newStringStream()
+
+ procs.writeImpl(ss, submsg)
+
+ subMessageData = ss.data
+
+ result = newgoogle_protobuf_Any()
+ result.typeUrl = typeUrl
+ result.value = cast[seq[byte]](subMessageData)
+
+declareJsonProcs(google_protobuf_Any)
+
+# Register the Well Known Types to the type registry automatically.
+
+template registerWkt(T: typedesc) =
+ var procs = `T ProcsWithJson`()
+ registerType("type.googleapis.com", fullyQualifiedName(T), procs)
+
+registerWkt(google_protobuf_Duration)
+registerWkt(google_protobuf_FieldMask)
+registerWkt(google_protobuf_Struct)
+registerWkt(google_protobuf_Value)
+registerWkt(google_protobuf_ListValue)
+registerWkt(google_protobuf_Timestamp)
+registerWkt(google_protobuf_DoubleValue)
+registerWkt(google_protobuf_FloatValue)
+registerWkt(google_protobuf_Int64Value)
+registerWkt(google_protobuf_UInt64Value)
+registerWkt(google_protobuf_Int32Value)
+registerWkt(google_protobuf_UInt32Value)
+registerWkt(google_protobuf_BoolValue)
+registerWkt(google_protobuf_StringValue)
+registerWkt(google_protobuf_BytesValue)
+registerWkt(google_protobuf_Any)
diff --git a/nimpb/wkt/any_pb.nim b/nimpb/wkt/any_pb.nim
index 440d2b3..92376cf 100644
--- a/nimpb/wkt/any_pb.nim
+++ b/nimpb/wkt/any_pb.nim
@@ -21,9 +21,19 @@ proc writegoogle_protobuf_Any*(stream: Stream, message: google_protobuf_Any)
proc readgoogle_protobuf_Any*(stream: Stream): google_protobuf_Any
proc sizeOfgoogle_protobuf_Any*(message: google_protobuf_Any): uint64
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Any]): string = "google.protobuf.Any"
+
+proc readgoogle_protobuf_AnyImpl(stream: Stream): Message = readgoogle_protobuf_Any(stream)
+proc writegoogle_protobuf_AnyImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Any(stream, google_protobuf_Any(msg))
+
+proc google_protobuf_AnyProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_AnyImpl
+ result.writeImpl = writegoogle_protobuf_AnyImpl
+
proc newgoogle_protobuf_Any*(): google_protobuf_Any =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_AnyProcs()
result.typeUrl = ""
result.value = @[]
diff --git a/nimpb/wkt/api_pb.nim b/nimpb/wkt/api_pb.nim
index 1aff6f2..47137e5 100644
--- a/nimpb/wkt/api_pb.nim
+++ b/nimpb/wkt/api_pb.nim
@@ -62,9 +62,23 @@ proc sizeOfgoogle_protobuf_Api*(message: google_protobuf_Api): uint64
proc toJson*(message: google_protobuf_Api): JsonNode
proc parsegoogle_protobuf_Api*(obj: JsonNode): google_protobuf_Api
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Method]): string = "google.protobuf.Method"
+
+proc readgoogle_protobuf_MethodImpl(stream: Stream): Message = readgoogle_protobuf_Method(stream)
+proc writegoogle_protobuf_MethodImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Method(stream, google_protobuf_Method(msg))
+proc toJsongoogle_protobuf_MethodImpl(msg: Message): JsonNode = toJson(google_protobuf_Method(msg))
+proc fromJsongoogle_protobuf_MethodImpl(node: JsonNode): Message = parsegoogle_protobuf_Method(node)
+
+proc google_protobuf_MethodProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_MethodImpl
+ result.writeImpl = writegoogle_protobuf_MethodImpl
+ result.toJsonImpl = toJsongoogle_protobuf_MethodImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_MethodImpl
+
proc newgoogle_protobuf_Method*(): google_protobuf_Method =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_MethodProcs()
result.name = ""
result.requestTypeUrl = ""
result.requestStreaming = false
@@ -306,9 +320,23 @@ proc newgoogle_protobuf_Method*(data: seq[byte]): google_protobuf_Method =
result = readgoogle_protobuf_Method(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Mixin]): string = "google.protobuf.Mixin"
+
+proc readgoogle_protobuf_MixinImpl(stream: Stream): Message = readgoogle_protobuf_Mixin(stream)
+proc writegoogle_protobuf_MixinImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Mixin(stream, google_protobuf_Mixin(msg))
+proc toJsongoogle_protobuf_MixinImpl(msg: Message): JsonNode = toJson(google_protobuf_Mixin(msg))
+proc fromJsongoogle_protobuf_MixinImpl(node: JsonNode): Message = parsegoogle_protobuf_Mixin(node)
+
+proc google_protobuf_MixinProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_MixinImpl
+ result.writeImpl = writegoogle_protobuf_MixinImpl
+ result.toJsonImpl = toJsongoogle_protobuf_MixinImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_MixinImpl
+
proc newgoogle_protobuf_Mixin*(): google_protobuf_Mixin =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_MixinProcs()
result.name = ""
result.root = ""
@@ -405,9 +433,23 @@ proc newgoogle_protobuf_Mixin*(data: seq[byte]): google_protobuf_Mixin =
result = readgoogle_protobuf_Mixin(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Api]): string = "google.protobuf.Api"
+
+proc readgoogle_protobuf_ApiImpl(stream: Stream): Message = readgoogle_protobuf_Api(stream)
+proc writegoogle_protobuf_ApiImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Api(stream, google_protobuf_Api(msg))
+proc toJsongoogle_protobuf_ApiImpl(msg: Message): JsonNode = toJson(google_protobuf_Api(msg))
+proc fromJsongoogle_protobuf_ApiImpl(node: JsonNode): Message = parsegoogle_protobuf_Api(node)
+
+proc google_protobuf_ApiProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_ApiImpl
+ result.writeImpl = writegoogle_protobuf_ApiImpl
+ result.toJsonImpl = toJsongoogle_protobuf_ApiImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_ApiImpl
+
proc newgoogle_protobuf_Api*(): google_protobuf_Api =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_ApiProcs()
result.name = ""
result.methods = @[]
result.options = @[]
diff --git a/nimpb/wkt/descriptor_pb.nim b/nimpb/wkt/descriptor_pb.nim
index 1627079..f7ee2f2 100644
--- a/nimpb/wkt/descriptor_pb.nim
+++ b/nimpb/wkt/descriptor_pb.nim
@@ -414,9 +414,19 @@ proc writegoogle_protobuf_GeneratedCodeInfo*(stream: Stream, message: google_pro
proc readgoogle_protobuf_GeneratedCodeInfo*(stream: Stream): google_protobuf_GeneratedCodeInfo
proc sizeOfgoogle_protobuf_GeneratedCodeInfo*(message: google_protobuf_GeneratedCodeInfo): uint64
+proc fullyQualifiedName*(T: typedesc[google_protobuf_UninterpretedOption_NamePart]): string = "google.protobuf.UninterpretedOption.NamePart"
+
+proc readgoogle_protobuf_UninterpretedOption_NamePartImpl(stream: Stream): Message = readgoogle_protobuf_UninterpretedOption_NamePart(stream)
+proc writegoogle_protobuf_UninterpretedOption_NamePartImpl(stream: Stream, msg: Message) = writegoogle_protobuf_UninterpretedOption_NamePart(stream, google_protobuf_UninterpretedOption_NamePart(msg))
+
+proc google_protobuf_UninterpretedOption_NamePartProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_UninterpretedOption_NamePartImpl
+ result.writeImpl = writegoogle_protobuf_UninterpretedOption_NamePartImpl
+
proc newgoogle_protobuf_UninterpretedOption_NamePart*(): google_protobuf_UninterpretedOption_NamePart =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_UninterpretedOption_NamePartProcs()
result.namePart = ""
result.isExtension = false
@@ -504,9 +514,19 @@ proc newgoogle_protobuf_UninterpretedOption_NamePart*(data: seq[byte]): google_p
result = readgoogle_protobuf_UninterpretedOption_NamePart(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_UninterpretedOption]): string = "google.protobuf.UninterpretedOption"
+
+proc readgoogle_protobuf_UninterpretedOptionImpl(stream: Stream): Message = readgoogle_protobuf_UninterpretedOption(stream)
+proc writegoogle_protobuf_UninterpretedOptionImpl(stream: Stream, msg: Message) = writegoogle_protobuf_UninterpretedOption(stream, google_protobuf_UninterpretedOption(msg))
+
+proc google_protobuf_UninterpretedOptionProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_UninterpretedOptionImpl
+ result.writeImpl = writegoogle_protobuf_UninterpretedOptionImpl
+
proc newgoogle_protobuf_UninterpretedOption*(): google_protobuf_UninterpretedOption =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_UninterpretedOptionProcs()
result.name = @[]
result.identifierValue = ""
result.positiveIntValue = 0
@@ -728,9 +748,19 @@ proc newgoogle_protobuf_UninterpretedOption*(data: seq[byte]): google_protobuf_U
result = readgoogle_protobuf_UninterpretedOption(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_EnumValueOptions]): string = "google.protobuf.EnumValueOptions"
+
+proc readgoogle_protobuf_EnumValueOptionsImpl(stream: Stream): Message = readgoogle_protobuf_EnumValueOptions(stream)
+proc writegoogle_protobuf_EnumValueOptionsImpl(stream: Stream, msg: Message) = writegoogle_protobuf_EnumValueOptions(stream, google_protobuf_EnumValueOptions(msg))
+
+proc google_protobuf_EnumValueOptionsProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_EnumValueOptionsImpl
+ result.writeImpl = writegoogle_protobuf_EnumValueOptionsImpl
+
proc newgoogle_protobuf_EnumValueOptions*(): google_protobuf_EnumValueOptions =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_EnumValueOptionsProcs()
result.deprecated = false
result.uninterpretedOption = @[]
@@ -822,9 +852,19 @@ proc newgoogle_protobuf_EnumValueOptions*(data: seq[byte]): google_protobuf_Enum
result = readgoogle_protobuf_EnumValueOptions(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_EnumValueDescriptorProto]): string = "google.protobuf.EnumValueDescriptorProto"
+
+proc readgoogle_protobuf_EnumValueDescriptorProtoImpl(stream: Stream): Message = readgoogle_protobuf_EnumValueDescriptorProto(stream)
+proc writegoogle_protobuf_EnumValueDescriptorProtoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_EnumValueDescriptorProto(stream, google_protobuf_EnumValueDescriptorProto(msg))
+
+proc google_protobuf_EnumValueDescriptorProtoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_EnumValueDescriptorProtoImpl
+ result.writeImpl = writegoogle_protobuf_EnumValueDescriptorProtoImpl
+
proc newgoogle_protobuf_EnumValueDescriptorProto*(): google_protobuf_EnumValueDescriptorProto =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_EnumValueDescriptorProtoProcs()
result.name = ""
result.number = 0
result.options = nil
@@ -939,9 +979,19 @@ proc newgoogle_protobuf_EnumValueDescriptorProto*(data: seq[byte]): google_proto
result = readgoogle_protobuf_EnumValueDescriptorProto(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_EnumDescriptorProto_EnumReservedRange]): string = "google.protobuf.EnumDescriptorProto.EnumReservedRange"
+
+proc readgoogle_protobuf_EnumDescriptorProto_EnumReservedRangeImpl(stream: Stream): Message = readgoogle_protobuf_EnumDescriptorProto_EnumReservedRange(stream)
+proc writegoogle_protobuf_EnumDescriptorProto_EnumReservedRangeImpl(stream: Stream, msg: Message) = writegoogle_protobuf_EnumDescriptorProto_EnumReservedRange(stream, google_protobuf_EnumDescriptorProto_EnumReservedRange(msg))
+
+proc google_protobuf_EnumDescriptorProto_EnumReservedRangeProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_EnumDescriptorProto_EnumReservedRangeImpl
+ result.writeImpl = writegoogle_protobuf_EnumDescriptorProto_EnumReservedRangeImpl
+
proc newgoogle_protobuf_EnumDescriptorProto_EnumReservedRange*(): google_protobuf_EnumDescriptorProto_EnumReservedRange =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_EnumDescriptorProto_EnumReservedRangeProcs()
result.start = 0
result.fend = 0
@@ -1029,9 +1079,19 @@ proc newgoogle_protobuf_EnumDescriptorProto_EnumReservedRange*(data: seq[byte]):
result = readgoogle_protobuf_EnumDescriptorProto_EnumReservedRange(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_EnumOptions]): string = "google.protobuf.EnumOptions"
+
+proc readgoogle_protobuf_EnumOptionsImpl(stream: Stream): Message = readgoogle_protobuf_EnumOptions(stream)
+proc writegoogle_protobuf_EnumOptionsImpl(stream: Stream, msg: Message) = writegoogle_protobuf_EnumOptions(stream, google_protobuf_EnumOptions(msg))
+
+proc google_protobuf_EnumOptionsProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_EnumOptionsImpl
+ result.writeImpl = writegoogle_protobuf_EnumOptionsImpl
+
proc newgoogle_protobuf_EnumOptions*(): google_protobuf_EnumOptions =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_EnumOptionsProcs()
result.allowAlias = false
result.deprecated = false
result.uninterpretedOption = @[]
@@ -1149,9 +1209,19 @@ proc newgoogle_protobuf_EnumOptions*(data: seq[byte]): google_protobuf_EnumOptio
result = readgoogle_protobuf_EnumOptions(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_EnumDescriptorProto]): string = "google.protobuf.EnumDescriptorProto"
+
+proc readgoogle_protobuf_EnumDescriptorProtoImpl(stream: Stream): Message = readgoogle_protobuf_EnumDescriptorProto(stream)
+proc writegoogle_protobuf_EnumDescriptorProtoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_EnumDescriptorProto(stream, google_protobuf_EnumDescriptorProto(msg))
+
+proc google_protobuf_EnumDescriptorProtoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_EnumDescriptorProtoImpl
+ result.writeImpl = writegoogle_protobuf_EnumDescriptorProtoImpl
+
proc newgoogle_protobuf_EnumDescriptorProto*(): google_protobuf_EnumDescriptorProto =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_EnumDescriptorProtoProcs()
result.name = ""
result.value = @[]
result.options = nil
@@ -1329,9 +1399,19 @@ proc newgoogle_protobuf_EnumDescriptorProto*(data: seq[byte]): google_protobuf_E
result = readgoogle_protobuf_EnumDescriptorProto(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_ExtensionRangeOptions]): string = "google.protobuf.ExtensionRangeOptions"
+
+proc readgoogle_protobuf_ExtensionRangeOptionsImpl(stream: Stream): Message = readgoogle_protobuf_ExtensionRangeOptions(stream)
+proc writegoogle_protobuf_ExtensionRangeOptionsImpl(stream: Stream, msg: Message) = writegoogle_protobuf_ExtensionRangeOptions(stream, google_protobuf_ExtensionRangeOptions(msg))
+
+proc google_protobuf_ExtensionRangeOptionsProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_ExtensionRangeOptionsImpl
+ result.writeImpl = writegoogle_protobuf_ExtensionRangeOptionsImpl
+
proc newgoogle_protobuf_ExtensionRangeOptions*(): google_protobuf_ExtensionRangeOptions =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_ExtensionRangeOptionsProcs()
result.uninterpretedOption = @[]
proc clearuninterpretedOption*(message: google_protobuf_ExtensionRangeOptions) =
@@ -1397,9 +1477,19 @@ proc newgoogle_protobuf_ExtensionRangeOptions*(data: seq[byte]): google_protobuf
result = readgoogle_protobuf_ExtensionRangeOptions(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_SourceCodeInfo_Location]): string = "google.protobuf.SourceCodeInfo.Location"
+
+proc readgoogle_protobuf_SourceCodeInfo_LocationImpl(stream: Stream): Message = readgoogle_protobuf_SourceCodeInfo_Location(stream)
+proc writegoogle_protobuf_SourceCodeInfo_LocationImpl(stream: Stream, msg: Message) = writegoogle_protobuf_SourceCodeInfo_Location(stream, google_protobuf_SourceCodeInfo_Location(msg))
+
+proc google_protobuf_SourceCodeInfo_LocationProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_SourceCodeInfo_LocationImpl
+ result.writeImpl = writegoogle_protobuf_SourceCodeInfo_LocationImpl
+
proc newgoogle_protobuf_SourceCodeInfo_Location*(): google_protobuf_SourceCodeInfo_Location =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_SourceCodeInfo_LocationProcs()
result.path = @[]
result.span = @[]
result.leadingComments = ""
@@ -1602,9 +1692,19 @@ proc newgoogle_protobuf_SourceCodeInfo_Location*(data: seq[byte]): google_protob
result = readgoogle_protobuf_SourceCodeInfo_Location(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_SourceCodeInfo]): string = "google.protobuf.SourceCodeInfo"
+
+proc readgoogle_protobuf_SourceCodeInfoImpl(stream: Stream): Message = readgoogle_protobuf_SourceCodeInfo(stream)
+proc writegoogle_protobuf_SourceCodeInfoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_SourceCodeInfo(stream, google_protobuf_SourceCodeInfo(msg))
+
+proc google_protobuf_SourceCodeInfoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_SourceCodeInfoImpl
+ result.writeImpl = writegoogle_protobuf_SourceCodeInfoImpl
+
proc newgoogle_protobuf_SourceCodeInfo*(): google_protobuf_SourceCodeInfo =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_SourceCodeInfoProcs()
result.location = @[]
proc clearlocation*(message: google_protobuf_SourceCodeInfo) =
@@ -1670,9 +1770,19 @@ proc newgoogle_protobuf_SourceCodeInfo*(data: seq[byte]): google_protobuf_Source
result = readgoogle_protobuf_SourceCodeInfo(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_FieldOptions]): string = "google.protobuf.FieldOptions"
+
+proc readgoogle_protobuf_FieldOptionsImpl(stream: Stream): Message = readgoogle_protobuf_FieldOptions(stream)
+proc writegoogle_protobuf_FieldOptionsImpl(stream: Stream, msg: Message) = writegoogle_protobuf_FieldOptions(stream, google_protobuf_FieldOptions(msg))
+
+proc google_protobuf_FieldOptionsProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_FieldOptionsImpl
+ result.writeImpl = writegoogle_protobuf_FieldOptionsImpl
+
proc newgoogle_protobuf_FieldOptions*(): google_protobuf_FieldOptions =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_FieldOptionsProcs()
result.ctype = google_protobuf_FieldOptions_CType.STRING
result.packed = false
result.jstype = google_protobuf_FieldOptions_JSType.JS_NORMAL
@@ -1894,9 +2004,19 @@ proc newgoogle_protobuf_FieldOptions*(data: seq[byte]): google_protobuf_FieldOpt
result = readgoogle_protobuf_FieldOptions(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_FieldDescriptorProto]): string = "google.protobuf.FieldDescriptorProto"
+
+proc readgoogle_protobuf_FieldDescriptorProtoImpl(stream: Stream): Message = readgoogle_protobuf_FieldDescriptorProto(stream)
+proc writegoogle_protobuf_FieldDescriptorProtoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_FieldDescriptorProto(stream, google_protobuf_FieldDescriptorProto(msg))
+
+proc google_protobuf_FieldDescriptorProtoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_FieldDescriptorProtoImpl
+ result.writeImpl = writegoogle_protobuf_FieldDescriptorProtoImpl
+
proc newgoogle_protobuf_FieldDescriptorProto*(): google_protobuf_FieldDescriptorProto =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_FieldDescriptorProtoProcs()
result.name = ""
result.number = 0
result.label = google_protobuf_FieldDescriptorProto_Label.LABEL_OPTIONAL
@@ -2193,9 +2313,19 @@ proc newgoogle_protobuf_FieldDescriptorProto*(data: seq[byte]): google_protobuf_
result = readgoogle_protobuf_FieldDescriptorProto(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_DescriptorProto_ExtensionRange]): string = "google.protobuf.DescriptorProto.ExtensionRange"
+
+proc readgoogle_protobuf_DescriptorProto_ExtensionRangeImpl(stream: Stream): Message = readgoogle_protobuf_DescriptorProto_ExtensionRange(stream)
+proc writegoogle_protobuf_DescriptorProto_ExtensionRangeImpl(stream: Stream, msg: Message) = writegoogle_protobuf_DescriptorProto_ExtensionRange(stream, google_protobuf_DescriptorProto_ExtensionRange(msg))
+
+proc google_protobuf_DescriptorProto_ExtensionRangeProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_DescriptorProto_ExtensionRangeImpl
+ result.writeImpl = writegoogle_protobuf_DescriptorProto_ExtensionRangeImpl
+
proc newgoogle_protobuf_DescriptorProto_ExtensionRange*(): google_protobuf_DescriptorProto_ExtensionRange =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_DescriptorProto_ExtensionRangeProcs()
result.start = 0
result.fend = 0
result.options = nil
@@ -2310,9 +2440,19 @@ proc newgoogle_protobuf_DescriptorProto_ExtensionRange*(data: seq[byte]): google
result = readgoogle_protobuf_DescriptorProto_ExtensionRange(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_MessageOptions]): string = "google.protobuf.MessageOptions"
+
+proc readgoogle_protobuf_MessageOptionsImpl(stream: Stream): Message = readgoogle_protobuf_MessageOptions(stream)
+proc writegoogle_protobuf_MessageOptionsImpl(stream: Stream, msg: Message) = writegoogle_protobuf_MessageOptions(stream, google_protobuf_MessageOptions(msg))
+
+proc google_protobuf_MessageOptionsProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_MessageOptionsImpl
+ result.writeImpl = writegoogle_protobuf_MessageOptionsImpl
+
proc newgoogle_protobuf_MessageOptions*(): google_protobuf_MessageOptions =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_MessageOptionsProcs()
result.messageSetWireFormat = false
result.noStandardDescriptorAccessor = false
result.deprecated = false
@@ -2482,9 +2622,19 @@ proc newgoogle_protobuf_MessageOptions*(data: seq[byte]): google_protobuf_Messag
result = readgoogle_protobuf_MessageOptions(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_OneofOptions]): string = "google.protobuf.OneofOptions"
+
+proc readgoogle_protobuf_OneofOptionsImpl(stream: Stream): Message = readgoogle_protobuf_OneofOptions(stream)
+proc writegoogle_protobuf_OneofOptionsImpl(stream: Stream, msg: Message) = writegoogle_protobuf_OneofOptions(stream, google_protobuf_OneofOptions(msg))
+
+proc google_protobuf_OneofOptionsProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_OneofOptionsImpl
+ result.writeImpl = writegoogle_protobuf_OneofOptionsImpl
+
proc newgoogle_protobuf_OneofOptions*(): google_protobuf_OneofOptions =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_OneofOptionsProcs()
result.uninterpretedOption = @[]
proc clearuninterpretedOption*(message: google_protobuf_OneofOptions) =
@@ -2550,9 +2700,19 @@ proc newgoogle_protobuf_OneofOptions*(data: seq[byte]): google_protobuf_OneofOpt
result = readgoogle_protobuf_OneofOptions(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_OneofDescriptorProto]): string = "google.protobuf.OneofDescriptorProto"
+
+proc readgoogle_protobuf_OneofDescriptorProtoImpl(stream: Stream): Message = readgoogle_protobuf_OneofDescriptorProto(stream)
+proc writegoogle_protobuf_OneofDescriptorProtoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_OneofDescriptorProto(stream, google_protobuf_OneofDescriptorProto(msg))
+
+proc google_protobuf_OneofDescriptorProtoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_OneofDescriptorProtoImpl
+ result.writeImpl = writegoogle_protobuf_OneofDescriptorProtoImpl
+
proc newgoogle_protobuf_OneofDescriptorProto*(): google_protobuf_OneofDescriptorProto =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_OneofDescriptorProtoProcs()
result.name = ""
result.options = nil
@@ -2641,9 +2801,19 @@ proc newgoogle_protobuf_OneofDescriptorProto*(data: seq[byte]): google_protobuf_
result = readgoogle_protobuf_OneofDescriptorProto(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_DescriptorProto_ReservedRange]): string = "google.protobuf.DescriptorProto.ReservedRange"
+
+proc readgoogle_protobuf_DescriptorProto_ReservedRangeImpl(stream: Stream): Message = readgoogle_protobuf_DescriptorProto_ReservedRange(stream)
+proc writegoogle_protobuf_DescriptorProto_ReservedRangeImpl(stream: Stream, msg: Message) = writegoogle_protobuf_DescriptorProto_ReservedRange(stream, google_protobuf_DescriptorProto_ReservedRange(msg))
+
+proc google_protobuf_DescriptorProto_ReservedRangeProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_DescriptorProto_ReservedRangeImpl
+ result.writeImpl = writegoogle_protobuf_DescriptorProto_ReservedRangeImpl
+
proc newgoogle_protobuf_DescriptorProto_ReservedRange*(): google_protobuf_DescriptorProto_ReservedRange =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_DescriptorProto_ReservedRangeProcs()
result.start = 0
result.fend = 0
@@ -2731,9 +2901,19 @@ proc newgoogle_protobuf_DescriptorProto_ReservedRange*(data: seq[byte]): google_
result = readgoogle_protobuf_DescriptorProto_ReservedRange(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_DescriptorProto]): string = "google.protobuf.DescriptorProto"
+
+proc readgoogle_protobuf_DescriptorProtoImpl(stream: Stream): Message = readgoogle_protobuf_DescriptorProto(stream)
+proc writegoogle_protobuf_DescriptorProtoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_DescriptorProto(stream, google_protobuf_DescriptorProto(msg))
+
+proc google_protobuf_DescriptorProtoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_DescriptorProtoImpl
+ result.writeImpl = writegoogle_protobuf_DescriptorProtoImpl
+
proc newgoogle_protobuf_DescriptorProto*(): google_protobuf_DescriptorProto =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_DescriptorProtoProcs()
result.name = ""
result.field = @[]
result.extension = @[]
@@ -3061,9 +3241,19 @@ proc newgoogle_protobuf_DescriptorProto*(data: seq[byte]): google_protobuf_Descr
result = readgoogle_protobuf_DescriptorProto(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_FileOptions]): string = "google.protobuf.FileOptions"
+
+proc readgoogle_protobuf_FileOptionsImpl(stream: Stream): Message = readgoogle_protobuf_FileOptions(stream)
+proc writegoogle_protobuf_FileOptionsImpl(stream: Stream, msg: Message) = writegoogle_protobuf_FileOptions(stream, google_protobuf_FileOptions(msg))
+
+proc google_protobuf_FileOptionsProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_FileOptionsImpl
+ result.writeImpl = writegoogle_protobuf_FileOptionsImpl
+
proc newgoogle_protobuf_FileOptions*(): google_protobuf_FileOptions =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_FileOptionsProcs()
result.javaPackage = ""
result.javaOuterClassname = ""
result.javaMultipleFiles = false
@@ -3597,9 +3787,19 @@ proc newgoogle_protobuf_FileOptions*(data: seq[byte]): google_protobuf_FileOptio
result = readgoogle_protobuf_FileOptions(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_ServiceOptions]): string = "google.protobuf.ServiceOptions"
+
+proc readgoogle_protobuf_ServiceOptionsImpl(stream: Stream): Message = readgoogle_protobuf_ServiceOptions(stream)
+proc writegoogle_protobuf_ServiceOptionsImpl(stream: Stream, msg: Message) = writegoogle_protobuf_ServiceOptions(stream, google_protobuf_ServiceOptions(msg))
+
+proc google_protobuf_ServiceOptionsProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_ServiceOptionsImpl
+ result.writeImpl = writegoogle_protobuf_ServiceOptionsImpl
+
proc newgoogle_protobuf_ServiceOptions*(): google_protobuf_ServiceOptions =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_ServiceOptionsProcs()
result.deprecated = false
result.uninterpretedOption = @[]
@@ -3691,9 +3891,19 @@ proc newgoogle_protobuf_ServiceOptions*(data: seq[byte]): google_protobuf_Servic
result = readgoogle_protobuf_ServiceOptions(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_MethodOptions]): string = "google.protobuf.MethodOptions"
+
+proc readgoogle_protobuf_MethodOptionsImpl(stream: Stream): Message = readgoogle_protobuf_MethodOptions(stream)
+proc writegoogle_protobuf_MethodOptionsImpl(stream: Stream, msg: Message) = writegoogle_protobuf_MethodOptions(stream, google_protobuf_MethodOptions(msg))
+
+proc google_protobuf_MethodOptionsProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_MethodOptionsImpl
+ result.writeImpl = writegoogle_protobuf_MethodOptionsImpl
+
proc newgoogle_protobuf_MethodOptions*(): google_protobuf_MethodOptions =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_MethodOptionsProcs()
result.deprecated = false
result.idempotencyLevel = google_protobuf_MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN
result.uninterpretedOption = @[]
@@ -3811,9 +4021,19 @@ proc newgoogle_protobuf_MethodOptions*(data: seq[byte]): google_protobuf_MethodO
result = readgoogle_protobuf_MethodOptions(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_MethodDescriptorProto]): string = "google.protobuf.MethodDescriptorProto"
+
+proc readgoogle_protobuf_MethodDescriptorProtoImpl(stream: Stream): Message = readgoogle_protobuf_MethodDescriptorProto(stream)
+proc writegoogle_protobuf_MethodDescriptorProtoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_MethodDescriptorProto(stream, google_protobuf_MethodDescriptorProto(msg))
+
+proc google_protobuf_MethodDescriptorProtoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_MethodDescriptorProtoImpl
+ result.writeImpl = writegoogle_protobuf_MethodDescriptorProtoImpl
+
proc newgoogle_protobuf_MethodDescriptorProto*(): google_protobuf_MethodDescriptorProto =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_MethodDescriptorProtoProcs()
result.name = ""
result.inputType = ""
result.outputType = ""
@@ -4006,9 +4226,19 @@ proc newgoogle_protobuf_MethodDescriptorProto*(data: seq[byte]): google_protobuf
result = readgoogle_protobuf_MethodDescriptorProto(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_ServiceDescriptorProto]): string = "google.protobuf.ServiceDescriptorProto"
+
+proc readgoogle_protobuf_ServiceDescriptorProtoImpl(stream: Stream): Message = readgoogle_protobuf_ServiceDescriptorProto(stream)
+proc writegoogle_protobuf_ServiceDescriptorProtoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_ServiceDescriptorProto(stream, google_protobuf_ServiceDescriptorProto(msg))
+
+proc google_protobuf_ServiceDescriptorProtoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_ServiceDescriptorProtoImpl
+ result.writeImpl = writegoogle_protobuf_ServiceDescriptorProtoImpl
+
proc newgoogle_protobuf_ServiceDescriptorProto*(): google_protobuf_ServiceDescriptorProto =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_ServiceDescriptorProtoProcs()
result.name = ""
result.fmethod = @[]
result.options = nil
@@ -4127,9 +4357,19 @@ proc newgoogle_protobuf_ServiceDescriptorProto*(data: seq[byte]): google_protobu
result = readgoogle_protobuf_ServiceDescriptorProto(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_FileDescriptorProto]): string = "google.protobuf.FileDescriptorProto"
+
+proc readgoogle_protobuf_FileDescriptorProtoImpl(stream: Stream): Message = readgoogle_protobuf_FileDescriptorProto(stream)
+proc writegoogle_protobuf_FileDescriptorProtoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_FileDescriptorProto(stream, google_protobuf_FileDescriptorProto(msg))
+
+proc google_protobuf_FileDescriptorProtoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_FileDescriptorProtoImpl
+ result.writeImpl = writegoogle_protobuf_FileDescriptorProtoImpl
+
proc newgoogle_protobuf_FileDescriptorProto*(): google_protobuf_FileDescriptorProto =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_FileDescriptorProtoProcs()
result.name = ""
result.package = ""
result.dependency = @[]
@@ -4526,9 +4766,19 @@ proc newgoogle_protobuf_FileDescriptorProto*(data: seq[byte]): google_protobuf_F
result = readgoogle_protobuf_FileDescriptorProto(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_FileDescriptorSet]): string = "google.protobuf.FileDescriptorSet"
+
+proc readgoogle_protobuf_FileDescriptorSetImpl(stream: Stream): Message = readgoogle_protobuf_FileDescriptorSet(stream)
+proc writegoogle_protobuf_FileDescriptorSetImpl(stream: Stream, msg: Message) = writegoogle_protobuf_FileDescriptorSet(stream, google_protobuf_FileDescriptorSet(msg))
+
+proc google_protobuf_FileDescriptorSetProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_FileDescriptorSetImpl
+ result.writeImpl = writegoogle_protobuf_FileDescriptorSetImpl
+
proc newgoogle_protobuf_FileDescriptorSet*(): google_protobuf_FileDescriptorSet =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_FileDescriptorSetProcs()
result.file = @[]
proc clearfile*(message: google_protobuf_FileDescriptorSet) =
@@ -4594,9 +4844,19 @@ proc newgoogle_protobuf_FileDescriptorSet*(data: seq[byte]): google_protobuf_Fil
result = readgoogle_protobuf_FileDescriptorSet(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_GeneratedCodeInfo_Annotation]): string = "google.protobuf.GeneratedCodeInfo.Annotation"
+
+proc readgoogle_protobuf_GeneratedCodeInfo_AnnotationImpl(stream: Stream): Message = readgoogle_protobuf_GeneratedCodeInfo_Annotation(stream)
+proc writegoogle_protobuf_GeneratedCodeInfo_AnnotationImpl(stream: Stream, msg: Message) = writegoogle_protobuf_GeneratedCodeInfo_Annotation(stream, google_protobuf_GeneratedCodeInfo_Annotation(msg))
+
+proc google_protobuf_GeneratedCodeInfo_AnnotationProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_GeneratedCodeInfo_AnnotationImpl
+ result.writeImpl = writegoogle_protobuf_GeneratedCodeInfo_AnnotationImpl
+
proc newgoogle_protobuf_GeneratedCodeInfo_Annotation*(): google_protobuf_GeneratedCodeInfo_Annotation =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_GeneratedCodeInfo_AnnotationProcs()
result.path = @[]
result.sourceFile = ""
result.begin = 0
@@ -4753,9 +5013,19 @@ proc newgoogle_protobuf_GeneratedCodeInfo_Annotation*(data: seq[byte]): google_p
result = readgoogle_protobuf_GeneratedCodeInfo_Annotation(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_GeneratedCodeInfo]): string = "google.protobuf.GeneratedCodeInfo"
+
+proc readgoogle_protobuf_GeneratedCodeInfoImpl(stream: Stream): Message = readgoogle_protobuf_GeneratedCodeInfo(stream)
+proc writegoogle_protobuf_GeneratedCodeInfoImpl(stream: Stream, msg: Message) = writegoogle_protobuf_GeneratedCodeInfo(stream, google_protobuf_GeneratedCodeInfo(msg))
+
+proc google_protobuf_GeneratedCodeInfoProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_GeneratedCodeInfoImpl
+ result.writeImpl = writegoogle_protobuf_GeneratedCodeInfoImpl
+
proc newgoogle_protobuf_GeneratedCodeInfo*(): google_protobuf_GeneratedCodeInfo =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_GeneratedCodeInfoProcs()
result.annotation = @[]
proc clearannotation*(message: google_protobuf_GeneratedCodeInfo) =
diff --git a/nimpb/wkt/duration.nim b/nimpb/wkt/duration.nim
index 46e03d4..36620b3 100644
--- a/nimpb/wkt/duration.nim
+++ b/nimpb/wkt/duration.nim
@@ -3,6 +3,7 @@ import math
import strutils
include duration_pb
+import utils
proc toJson*(message: google_protobuf_Duration): JsonNode =
if (message.seconds < -315_576_000_000'i64) or
@@ -66,3 +67,5 @@ proc parsegoogle_protobuf_Duration*(node: JsonNode): google_protobuf_Duration =
if result.seconds < 0:
setNanos(result, -result.nanos)
+
+declareJsonProcs(google_protobuf_Duration)
diff --git a/nimpb/wkt/duration_pb.nim b/nimpb/wkt/duration_pb.nim
index 6359c20..72b864d 100644
--- a/nimpb/wkt/duration_pb.nim
+++ b/nimpb/wkt/duration_pb.nim
@@ -21,9 +21,19 @@ proc writegoogle_protobuf_Duration*(stream: Stream, message: google_protobuf_Dur
proc readgoogle_protobuf_Duration*(stream: Stream): google_protobuf_Duration
proc sizeOfgoogle_protobuf_Duration*(message: google_protobuf_Duration): uint64
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Duration]): string = "google.protobuf.Duration"
+
+proc readgoogle_protobuf_DurationImpl(stream: Stream): Message = readgoogle_protobuf_Duration(stream)
+proc writegoogle_protobuf_DurationImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Duration(stream, google_protobuf_Duration(msg))
+
+proc google_protobuf_DurationProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_DurationImpl
+ result.writeImpl = writegoogle_protobuf_DurationImpl
+
proc newgoogle_protobuf_Duration*(): google_protobuf_Duration =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_DurationProcs()
result.seconds = 0
result.nanos = 0
diff --git a/nimpb/wkt/empty_pb.nim b/nimpb/wkt/empty_pb.nim
index 88ebf66..13fb31f 100644
--- a/nimpb/wkt/empty_pb.nim
+++ b/nimpb/wkt/empty_pb.nim
@@ -21,9 +21,23 @@ proc sizeOfgoogle_protobuf_Empty*(message: google_protobuf_Empty): uint64
proc toJson*(message: google_protobuf_Empty): JsonNode
proc parsegoogle_protobuf_Empty*(obj: JsonNode): google_protobuf_Empty
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Empty]): string = "google.protobuf.Empty"
+
+proc readgoogle_protobuf_EmptyImpl(stream: Stream): Message = readgoogle_protobuf_Empty(stream)
+proc writegoogle_protobuf_EmptyImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Empty(stream, google_protobuf_Empty(msg))
+proc toJsongoogle_protobuf_EmptyImpl(msg: Message): JsonNode = toJson(google_protobuf_Empty(msg))
+proc fromJsongoogle_protobuf_EmptyImpl(node: JsonNode): Message = parsegoogle_protobuf_Empty(node)
+
+proc google_protobuf_EmptyProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_EmptyImpl
+ result.writeImpl = writegoogle_protobuf_EmptyImpl
+ result.toJsonImpl = toJsongoogle_protobuf_EmptyImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_EmptyImpl
+
proc newgoogle_protobuf_Empty*(): google_protobuf_Empty =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_EmptyProcs()
proc sizeOfgoogle_protobuf_Empty*(message: google_protobuf_Empty): uint64 =
result = result + sizeOfUnknownFields(message)
diff --git a/nimpb/wkt/field_mask.nim b/nimpb/wkt/field_mask.nim
index 72f541b..ba12811 100644
--- a/nimpb/wkt/field_mask.nim
+++ b/nimpb/wkt/field_mask.nim
@@ -2,6 +2,7 @@ import json
import strutils
include field_mask_pb
+import utils
const
LowerCaseLetters = {'a'..'z'}
@@ -64,3 +65,5 @@ proc parsegoogle_protobuf_FieldMask*(node: JsonNode): google_protobuf_FieldMask
addPaths(result, camelCaseToSnakeCase(path))
except ValueError as exc:
raise newException(nimpb_json.ParseError, exc.msg)
+
+declareJsonProcs(google_protobuf_FieldMask)
diff --git a/nimpb/wkt/field_mask_pb.nim b/nimpb/wkt/field_mask_pb.nim
index 91b58bb..16be527 100644
--- a/nimpb/wkt/field_mask_pb.nim
+++ b/nimpb/wkt/field_mask_pb.nim
@@ -20,9 +20,19 @@ proc writegoogle_protobuf_FieldMask*(stream: Stream, message: google_protobuf_Fi
proc readgoogle_protobuf_FieldMask*(stream: Stream): google_protobuf_FieldMask
proc sizeOfgoogle_protobuf_FieldMask*(message: google_protobuf_FieldMask): uint64
+proc fullyQualifiedName*(T: typedesc[google_protobuf_FieldMask]): string = "google.protobuf.FieldMask"
+
+proc readgoogle_protobuf_FieldMaskImpl(stream: Stream): Message = readgoogle_protobuf_FieldMask(stream)
+proc writegoogle_protobuf_FieldMaskImpl(stream: Stream, msg: Message) = writegoogle_protobuf_FieldMask(stream, google_protobuf_FieldMask(msg))
+
+proc google_protobuf_FieldMaskProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_FieldMaskImpl
+ result.writeImpl = writegoogle_protobuf_FieldMaskImpl
+
proc newgoogle_protobuf_FieldMask*(): google_protobuf_FieldMask =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_FieldMaskProcs()
result.paths = @[]
proc clearpaths*(message: google_protobuf_FieldMask) =
diff --git a/nimpb/wkt/source_context_pb.nim b/nimpb/wkt/source_context_pb.nim
index 1df97c9..aac1b81 100644
--- a/nimpb/wkt/source_context_pb.nim
+++ b/nimpb/wkt/source_context_pb.nim
@@ -22,9 +22,23 @@ proc sizeOfgoogle_protobuf_SourceContext*(message: google_protobuf_SourceContext
proc toJson*(message: google_protobuf_SourceContext): JsonNode
proc parsegoogle_protobuf_SourceContext*(obj: JsonNode): google_protobuf_SourceContext
+proc fullyQualifiedName*(T: typedesc[google_protobuf_SourceContext]): string = "google.protobuf.SourceContext"
+
+proc readgoogle_protobuf_SourceContextImpl(stream: Stream): Message = readgoogle_protobuf_SourceContext(stream)
+proc writegoogle_protobuf_SourceContextImpl(stream: Stream, msg: Message) = writegoogle_protobuf_SourceContext(stream, google_protobuf_SourceContext(msg))
+proc toJsongoogle_protobuf_SourceContextImpl(msg: Message): JsonNode = toJson(google_protobuf_SourceContext(msg))
+proc fromJsongoogle_protobuf_SourceContextImpl(node: JsonNode): Message = parsegoogle_protobuf_SourceContext(node)
+
+proc google_protobuf_SourceContextProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_SourceContextImpl
+ result.writeImpl = writegoogle_protobuf_SourceContextImpl
+ result.toJsonImpl = toJsongoogle_protobuf_SourceContextImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_SourceContextImpl
+
proc newgoogle_protobuf_SourceContext*(): google_protobuf_SourceContext =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_SourceContextProcs()
result.fileName = ""
proc clearfileName*(message: google_protobuf_SourceContext) =
diff --git a/nimpb/wkt/struct.nim b/nimpb/wkt/struct.nim
index 659af58..64f0112 100644
--- a/nimpb/wkt/struct.nim
+++ b/nimpb/wkt/struct.nim
@@ -1,6 +1,7 @@
import json
include struct_pb
+import utils
proc toJson*(message: google_protobuf_Value): JsonNode
@@ -78,3 +79,8 @@ proc parsegoogle_protobuf_ListValue*(node: JsonNode): google_protobuf_ListValue
for value in node:
addValues(result, parsegoogle_protobuf_Value(value))
+
+declareJsonProcs(google_protobuf_Value)
+declareJsonProcs(google_protobuf_ListValue)
+declareJsonProcs(google_protobuf_Struct)
+# helper(google_protobuf_NullValue)
diff --git a/nimpb/wkt/struct_pb.nim b/nimpb/wkt/struct_pb.nim
index 0944989..78538ac 100644
--- a/nimpb/wkt/struct_pb.nim
+++ b/nimpb/wkt/struct_pb.nim
@@ -106,9 +106,19 @@ proc readgoogle_protobuf_Struct_FieldsEntryKV(stream: Stream, tbl: TableRef[stri
tbl[key] = value
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Struct]): string = "google.protobuf.Struct"
+
+proc readgoogle_protobuf_StructImpl(stream: Stream): Message = readgoogle_protobuf_Struct(stream)
+proc writegoogle_protobuf_StructImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Struct(stream, google_protobuf_Struct(msg))
+
+proc google_protobuf_StructProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_StructImpl
+ result.writeImpl = writegoogle_protobuf_StructImpl
+
proc newgoogle_protobuf_Struct*(): google_protobuf_Struct =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_StructProcs()
result.fields = newTable[string, google_protobuf_Value]()
proc clearfields*(message: google_protobuf_Struct) =
@@ -174,9 +184,19 @@ proc newgoogle_protobuf_Struct*(data: seq[byte]): google_protobuf_Struct =
result = readgoogle_protobuf_Struct(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_ListValue]): string = "google.protobuf.ListValue"
+
+proc readgoogle_protobuf_ListValueImpl(stream: Stream): Message = readgoogle_protobuf_ListValue(stream)
+proc writegoogle_protobuf_ListValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_ListValue(stream, google_protobuf_ListValue(msg))
+
+proc google_protobuf_ListValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_ListValueImpl
+ result.writeImpl = writegoogle_protobuf_ListValueImpl
+
proc newgoogle_protobuf_ListValue*(): google_protobuf_ListValue =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_ListValueProcs()
result.values = @[]
proc clearvalues*(message: google_protobuf_ListValue) =
@@ -242,9 +262,19 @@ proc newgoogle_protobuf_ListValue*(data: seq[byte]): google_protobuf_ListValue =
result = readgoogle_protobuf_ListValue(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Value]): string = "google.protobuf.Value"
+
+proc readgoogle_protobuf_ValueImpl(stream: Stream): Message = readgoogle_protobuf_Value(stream)
+proc writegoogle_protobuf_ValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Value(stream, google_protobuf_Value(msg))
+
+proc google_protobuf_ValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_ValueImpl
+ result.writeImpl = writegoogle_protobuf_ValueImpl
+
proc newgoogle_protobuf_Value*(): google_protobuf_Value =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_ValueProcs()
result.kind.kind = google_protobuf_Value_kind_Kind.NotSet
proc clearnullValue*(message: google_protobuf_Value) =
diff --git a/nimpb/wkt/timestamp.nim b/nimpb/wkt/timestamp.nim
index 16134e3..3d174fe 100644
--- a/nimpb/wkt/timestamp.nim
+++ b/nimpb/wkt/timestamp.nim
@@ -4,6 +4,7 @@ import strutils
import times
include timestamp_pb
+import utils
proc toJson*(message: google_protobuf_Timestamp): JsonNode =
let t = utc(fromUnix(message.seconds))
@@ -71,3 +72,5 @@ offset <- 'Z' / (('+' / '-') \d\d ':' \d\d)
setSeconds(result, toUnix(toTime(dt)))
setNanos(result, int32(nanos))
+
+declareJsonProcs(google_protobuf_Timestamp)
diff --git a/nimpb/wkt/timestamp_pb.nim b/nimpb/wkt/timestamp_pb.nim
index b0a7420..c1668dd 100644
--- a/nimpb/wkt/timestamp_pb.nim
+++ b/nimpb/wkt/timestamp_pb.nim
@@ -21,9 +21,19 @@ proc writegoogle_protobuf_Timestamp*(stream: Stream, message: google_protobuf_Ti
proc readgoogle_protobuf_Timestamp*(stream: Stream): google_protobuf_Timestamp
proc sizeOfgoogle_protobuf_Timestamp*(message: google_protobuf_Timestamp): uint64
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Timestamp]): string = "google.protobuf.Timestamp"
+
+proc readgoogle_protobuf_TimestampImpl(stream: Stream): Message = readgoogle_protobuf_Timestamp(stream)
+proc writegoogle_protobuf_TimestampImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Timestamp(stream, google_protobuf_Timestamp(msg))
+
+proc google_protobuf_TimestampProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_TimestampImpl
+ result.writeImpl = writegoogle_protobuf_TimestampImpl
+
proc newgoogle_protobuf_Timestamp*(): google_protobuf_Timestamp =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_TimestampProcs()
result.seconds = 0
result.nanos = 0
diff --git a/nimpb/wkt/type_pb.nim b/nimpb/wkt/type_pb.nim
index 4c87659..9c72b4a 100644
--- a/nimpb/wkt/type_pb.nim
+++ b/nimpb/wkt/type_pb.nim
@@ -122,9 +122,23 @@ proc sizeOfgoogle_protobuf_Enum*(message: google_protobuf_Enum): uint64
proc toJson*(message: google_protobuf_Enum): JsonNode
proc parsegoogle_protobuf_Enum*(obj: JsonNode): google_protobuf_Enum
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Option]): string = "google.protobuf.Option"
+
+proc readgoogle_protobuf_OptionImpl(stream: Stream): Message = readgoogle_protobuf_Option(stream)
+proc writegoogle_protobuf_OptionImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Option(stream, google_protobuf_Option(msg))
+proc toJsongoogle_protobuf_OptionImpl(msg: Message): JsonNode = toJson(google_protobuf_Option(msg))
+proc fromJsongoogle_protobuf_OptionImpl(node: JsonNode): Message = parsegoogle_protobuf_Option(node)
+
+proc google_protobuf_OptionProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_OptionImpl
+ result.writeImpl = writegoogle_protobuf_OptionImpl
+ result.toJsonImpl = toJsongoogle_protobuf_OptionImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_OptionImpl
+
proc newgoogle_protobuf_Option*(): google_protobuf_Option =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_OptionProcs()
result.name = ""
result.value = nil
@@ -227,9 +241,23 @@ proc newgoogle_protobuf_Option*(data: seq[byte]): google_protobuf_Option =
result = readgoogle_protobuf_Option(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Field]): string = "google.protobuf.Field"
+
+proc readgoogle_protobuf_FieldImpl(stream: Stream): Message = readgoogle_protobuf_Field(stream)
+proc writegoogle_protobuf_FieldImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Field(stream, google_protobuf_Field(msg))
+proc toJsongoogle_protobuf_FieldImpl(msg: Message): JsonNode = toJson(google_protobuf_Field(msg))
+proc fromJsongoogle_protobuf_FieldImpl(node: JsonNode): Message = parsegoogle_protobuf_Field(node)
+
+proc google_protobuf_FieldProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_FieldImpl
+ result.writeImpl = writegoogle_protobuf_FieldImpl
+ result.toJsonImpl = toJsongoogle_protobuf_FieldImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_FieldImpl
+
proc newgoogle_protobuf_Field*(): google_protobuf_Field =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_FieldProcs()
result.kind = google_protobuf_Field_Kind.TYPE_UNKNOWN
result.cardinality = google_protobuf_Field_Cardinality.CARDINALITY_UNKNOWN
result.number = 0
@@ -549,9 +577,23 @@ proc newgoogle_protobuf_Field*(data: seq[byte]): google_protobuf_Field =
result = readgoogle_protobuf_Field(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Type]): string = "google.protobuf.Type"
+
+proc readgoogle_protobuf_TypeImpl(stream: Stream): Message = readgoogle_protobuf_Type(stream)
+proc writegoogle_protobuf_TypeImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Type(stream, google_protobuf_Type(msg))
+proc toJsongoogle_protobuf_TypeImpl(msg: Message): JsonNode = toJson(google_protobuf_Type(msg))
+proc fromJsongoogle_protobuf_TypeImpl(node: JsonNode): Message = parsegoogle_protobuf_Type(node)
+
+proc google_protobuf_TypeProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_TypeImpl
+ result.writeImpl = writegoogle_protobuf_TypeImpl
+ result.toJsonImpl = toJsongoogle_protobuf_TypeImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_TypeImpl
+
proc newgoogle_protobuf_Type*(): google_protobuf_Type =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_TypeProcs()
result.name = ""
result.fields = @[]
result.oneofs = @[]
@@ -797,9 +839,23 @@ proc newgoogle_protobuf_Type*(data: seq[byte]): google_protobuf_Type =
result = readgoogle_protobuf_Type(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_EnumValue]): string = "google.protobuf.EnumValue"
+
+proc readgoogle_protobuf_EnumValueImpl(stream: Stream): Message = readgoogle_protobuf_EnumValue(stream)
+proc writegoogle_protobuf_EnumValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_EnumValue(stream, google_protobuf_EnumValue(msg))
+proc toJsongoogle_protobuf_EnumValueImpl(msg: Message): JsonNode = toJson(google_protobuf_EnumValue(msg))
+proc fromJsongoogle_protobuf_EnumValueImpl(node: JsonNode): Message = parsegoogle_protobuf_EnumValue(node)
+
+proc google_protobuf_EnumValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_EnumValueImpl
+ result.writeImpl = writegoogle_protobuf_EnumValueImpl
+ result.toJsonImpl = toJsongoogle_protobuf_EnumValueImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_EnumValueImpl
+
proc newgoogle_protobuf_EnumValue*(): google_protobuf_EnumValue =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_EnumValueProcs()
result.name = ""
result.number = 0
result.options = @[]
@@ -937,9 +993,23 @@ proc newgoogle_protobuf_EnumValue*(data: seq[byte]): google_protobuf_EnumValue =
result = readgoogle_protobuf_EnumValue(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Enum]): string = "google.protobuf.Enum"
+
+proc readgoogle_protobuf_EnumImpl(stream: Stream): Message = readgoogle_protobuf_Enum(stream)
+proc writegoogle_protobuf_EnumImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Enum(stream, google_protobuf_Enum(msg))
+proc toJsongoogle_protobuf_EnumImpl(msg: Message): JsonNode = toJson(google_protobuf_Enum(msg))
+proc fromJsongoogle_protobuf_EnumImpl(node: JsonNode): Message = parsegoogle_protobuf_Enum(node)
+
+proc google_protobuf_EnumProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_EnumImpl
+ result.writeImpl = writegoogle_protobuf_EnumImpl
+ result.toJsonImpl = toJsongoogle_protobuf_EnumImpl
+ result.fromJsonImpl = fromJsongoogle_protobuf_EnumImpl
+
proc newgoogle_protobuf_Enum*(): google_protobuf_Enum =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_EnumProcs()
result.name = ""
result.enumvalue = @[]
result.options = @[]
diff --git a/nimpb/wkt/utils.nim b/nimpb/wkt/utils.nim
new file mode 100644
index 0000000..243debc
--- /dev/null
+++ b/nimpb/wkt/utils.nim
@@ -0,0 +1,11 @@
+template declareJsonProcs*(T: typedesc) =
+ proc `T FromJsonImpl`(node: JsonNode): Message =
+ `parse T`(node)
+
+ proc `T ToJsonImpl`(msg: Message): JsonNode =
+ toJson(T(msg))
+
+ proc `T ProcsWithJson`*(): MessageProcs =
+ result = `T Procs`()
+ result.fromJsonImpl = `T FromJsonImpl`
+ result.toJsonImpl = `T ToJsonImpl`
diff --git a/nimpb/wkt/wrappers.nim b/nimpb/wkt/wrappers.nim
index f4c42fa..ad03635 100644
--- a/nimpb/wkt/wrappers.nim
+++ b/nimpb/wkt/wrappers.nim
@@ -3,6 +3,7 @@ import strutils
import base64
include wrappers_pb
+import utils
proc toJson*(message: google_protobuf_DoubleValue): JsonNode =
toJson(message.value)
@@ -98,3 +99,13 @@ proc parsegoogle_protobuf_BytesValue*(node: JsonNode): google_protobuf_BytesValu
raise newException(nimpb_json.ParseError, "not a string")
result = newgoogle_protobuf_BytesValue()
setValue(result, cast[seq[byte]](base64.decode(node.str)))
+
+declareJsonProcs(google_protobuf_DoubleValue)
+declareJsonProcs(google_protobuf_FloatValue)
+declareJsonProcs(google_protobuf_Int64Value)
+declareJsonProcs(google_protobuf_UInt64Value)
+declareJsonProcs(google_protobuf_Int32Value)
+declareJsonProcs(google_protobuf_UInt32Value)
+declareJsonProcs(google_protobuf_BoolValue)
+declareJsonProcs(google_protobuf_StringValue)
+declareJsonProcs(google_protobuf_BytesValue)
diff --git a/nimpb/wkt/wrappers_pb.nim b/nimpb/wkt/wrappers_pb.nim
index a0b3432..01ace8a 100644
--- a/nimpb/wkt/wrappers_pb.nim
+++ b/nimpb/wkt/wrappers_pb.nim
@@ -100,9 +100,19 @@ proc writegoogle_protobuf_UInt32Value*(stream: Stream, message: google_protobuf_
proc readgoogle_protobuf_UInt32Value*(stream: Stream): google_protobuf_UInt32Value
proc sizeOfgoogle_protobuf_UInt32Value*(message: google_protobuf_UInt32Value): uint64
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Int32Value]): string = "google.protobuf.Int32Value"
+
+proc readgoogle_protobuf_Int32ValueImpl(stream: Stream): Message = readgoogle_protobuf_Int32Value(stream)
+proc writegoogle_protobuf_Int32ValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Int32Value(stream, google_protobuf_Int32Value(msg))
+
+proc google_protobuf_Int32ValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_Int32ValueImpl
+ result.writeImpl = writegoogle_protobuf_Int32ValueImpl
+
proc newgoogle_protobuf_Int32Value*(): google_protobuf_Int32Value =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_Int32ValueProcs()
result.value = 0
proc clearvalue*(message: google_protobuf_Int32Value) =
@@ -159,9 +169,19 @@ proc newgoogle_protobuf_Int32Value*(data: seq[byte]): google_protobuf_Int32Value
result = readgoogle_protobuf_Int32Value(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_Int64Value]): string = "google.protobuf.Int64Value"
+
+proc readgoogle_protobuf_Int64ValueImpl(stream: Stream): Message = readgoogle_protobuf_Int64Value(stream)
+proc writegoogle_protobuf_Int64ValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_Int64Value(stream, google_protobuf_Int64Value(msg))
+
+proc google_protobuf_Int64ValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_Int64ValueImpl
+ result.writeImpl = writegoogle_protobuf_Int64ValueImpl
+
proc newgoogle_protobuf_Int64Value*(): google_protobuf_Int64Value =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_Int64ValueProcs()
result.value = 0
proc clearvalue*(message: google_protobuf_Int64Value) =
@@ -218,9 +238,19 @@ proc newgoogle_protobuf_Int64Value*(data: seq[byte]): google_protobuf_Int64Value
result = readgoogle_protobuf_Int64Value(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_DoubleValue]): string = "google.protobuf.DoubleValue"
+
+proc readgoogle_protobuf_DoubleValueImpl(stream: Stream): Message = readgoogle_protobuf_DoubleValue(stream)
+proc writegoogle_protobuf_DoubleValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_DoubleValue(stream, google_protobuf_DoubleValue(msg))
+
+proc google_protobuf_DoubleValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_DoubleValueImpl
+ result.writeImpl = writegoogle_protobuf_DoubleValueImpl
+
proc newgoogle_protobuf_DoubleValue*(): google_protobuf_DoubleValue =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_DoubleValueProcs()
result.value = 0
proc clearvalue*(message: google_protobuf_DoubleValue) =
@@ -277,9 +307,19 @@ proc newgoogle_protobuf_DoubleValue*(data: seq[byte]): google_protobuf_DoubleVal
result = readgoogle_protobuf_DoubleValue(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_StringValue]): string = "google.protobuf.StringValue"
+
+proc readgoogle_protobuf_StringValueImpl(stream: Stream): Message = readgoogle_protobuf_StringValue(stream)
+proc writegoogle_protobuf_StringValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_StringValue(stream, google_protobuf_StringValue(msg))
+
+proc google_protobuf_StringValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_StringValueImpl
+ result.writeImpl = writegoogle_protobuf_StringValueImpl
+
proc newgoogle_protobuf_StringValue*(): google_protobuf_StringValue =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_StringValueProcs()
result.value = ""
proc clearvalue*(message: google_protobuf_StringValue) =
@@ -336,9 +376,19 @@ proc newgoogle_protobuf_StringValue*(data: seq[byte]): google_protobuf_StringVal
result = readgoogle_protobuf_StringValue(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_BoolValue]): string = "google.protobuf.BoolValue"
+
+proc readgoogle_protobuf_BoolValueImpl(stream: Stream): Message = readgoogle_protobuf_BoolValue(stream)
+proc writegoogle_protobuf_BoolValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_BoolValue(stream, google_protobuf_BoolValue(msg))
+
+proc google_protobuf_BoolValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_BoolValueImpl
+ result.writeImpl = writegoogle_protobuf_BoolValueImpl
+
proc newgoogle_protobuf_BoolValue*(): google_protobuf_BoolValue =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_BoolValueProcs()
result.value = false
proc clearvalue*(message: google_protobuf_BoolValue) =
@@ -395,9 +445,19 @@ proc newgoogle_protobuf_BoolValue*(data: seq[byte]): google_protobuf_BoolValue =
result = readgoogle_protobuf_BoolValue(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_BytesValue]): string = "google.protobuf.BytesValue"
+
+proc readgoogle_protobuf_BytesValueImpl(stream: Stream): Message = readgoogle_protobuf_BytesValue(stream)
+proc writegoogle_protobuf_BytesValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_BytesValue(stream, google_protobuf_BytesValue(msg))
+
+proc google_protobuf_BytesValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_BytesValueImpl
+ result.writeImpl = writegoogle_protobuf_BytesValueImpl
+
proc newgoogle_protobuf_BytesValue*(): google_protobuf_BytesValue =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_BytesValueProcs()
result.value = @[]
proc clearvalue*(message: google_protobuf_BytesValue) =
@@ -454,9 +514,19 @@ proc newgoogle_protobuf_BytesValue*(data: seq[byte]): google_protobuf_BytesValue
result = readgoogle_protobuf_BytesValue(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_FloatValue]): string = "google.protobuf.FloatValue"
+
+proc readgoogle_protobuf_FloatValueImpl(stream: Stream): Message = readgoogle_protobuf_FloatValue(stream)
+proc writegoogle_protobuf_FloatValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_FloatValue(stream, google_protobuf_FloatValue(msg))
+
+proc google_protobuf_FloatValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_FloatValueImpl
+ result.writeImpl = writegoogle_protobuf_FloatValueImpl
+
proc newgoogle_protobuf_FloatValue*(): google_protobuf_FloatValue =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_FloatValueProcs()
result.value = 0
proc clearvalue*(message: google_protobuf_FloatValue) =
@@ -513,9 +583,19 @@ proc newgoogle_protobuf_FloatValue*(data: seq[byte]): google_protobuf_FloatValue
result = readgoogle_protobuf_FloatValue(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_UInt64Value]): string = "google.protobuf.UInt64Value"
+
+proc readgoogle_protobuf_UInt64ValueImpl(stream: Stream): Message = readgoogle_protobuf_UInt64Value(stream)
+proc writegoogle_protobuf_UInt64ValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_UInt64Value(stream, google_protobuf_UInt64Value(msg))
+
+proc google_protobuf_UInt64ValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_UInt64ValueImpl
+ result.writeImpl = writegoogle_protobuf_UInt64ValueImpl
+
proc newgoogle_protobuf_UInt64Value*(): google_protobuf_UInt64Value =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_UInt64ValueProcs()
result.value = 0
proc clearvalue*(message: google_protobuf_UInt64Value) =
@@ -572,9 +652,19 @@ proc newgoogle_protobuf_UInt64Value*(data: seq[byte]): google_protobuf_UInt64Val
result = readgoogle_protobuf_UInt64Value(ss)
+proc fullyQualifiedName*(T: typedesc[google_protobuf_UInt32Value]): string = "google.protobuf.UInt32Value"
+
+proc readgoogle_protobuf_UInt32ValueImpl(stream: Stream): Message = readgoogle_protobuf_UInt32Value(stream)
+proc writegoogle_protobuf_UInt32ValueImpl(stream: Stream, msg: Message) = writegoogle_protobuf_UInt32Value(stream, google_protobuf_UInt32Value(msg))
+
+proc google_protobuf_UInt32ValueProcs*(): MessageProcs =
+ result.readImpl = readgoogle_protobuf_UInt32ValueImpl
+ result.writeImpl = writegoogle_protobuf_UInt32ValueImpl
+
proc newgoogle_protobuf_UInt32Value*(): google_protobuf_UInt32Value =
new(result)
initMessage(result[])
+ result.procs = google_protobuf_UInt32ValueProcs()
result.value = 0
proc clearvalue*(message: google_protobuf_UInt32Value) =
diff --git a/tests/conformance/conformance_nim.nim b/tests/conformance/conformance_nim.nim
index 819a7c9..1b73517 100644
--- a/tests/conformance/conformance_nim.nim
+++ b/tests/conformance/conformance_nim.nim
@@ -4,6 +4,7 @@ import streams
import strformat
import nimpb/nimpb
+import nimpb/wkt/any
import conformance_pb
import test_messages_proto3_pb
@@ -30,6 +31,8 @@ proc myReadString(s: Stream, size: int): string =
proc errorMessage(exc: ref Exception): string =
result = $exc.name & ": " & exc.msg & "\n" & getStackTrace(exc)
+any.registerType(protobuf_test_messages_proto3_TestAllTypesProto3)
+
while true:
var requestSize = 0'i32