Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/generate.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const package_regex = r"package\s(\S*)[\s]*;.*"
const service_regex = r"service\s(\S*)[\s]*{.*"
const service_regex = r"service\s(\S*)[\s]*.*"

function write_header(io, generated_module, package, client_module_name)
print(io, """module $(client_module_name)
Expand Down Expand Up @@ -99,7 +99,7 @@ function detect_services(proto::String)
if (regexmatches !== nothing) && (length(regexmatches.captures) == 1)
package = string(first(regexmatches.captures))
end
elseif startswith(strip(line), "service")
elseif startswith(line, "service")
regexmatches = match(service_regex, line)
if (regexmatches !== nothing) && (length(regexmatches.captures) == 1)
service = string(first(regexmatches.captures))
Expand Down
4 changes: 3 additions & 1 deletion test/GrpcerrorsClients/grpcerrors_pb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ mutable struct Data <: ProtoType
fldname, fldval = nv
fldtype = symdict[fldname].jtyp
(fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
if fldval !== nothing
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
end
end
obj
end
Expand Down
20 changes: 15 additions & 5 deletions test/RouteguideClients/route_guide_pb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ mutable struct Point <: ProtoType
fldname, fldval = nv
fldtype = symdict[fldname].jtyp
(fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
if fldval !== nothing
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
end
end
obj
end
Expand Down Expand Up @@ -54,7 +56,9 @@ mutable struct Rectangle <: ProtoType
fldname, fldval = nv
fldtype = symdict[fldname].jtyp
(fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
if fldval !== nothing
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
end
end
obj
end
Expand Down Expand Up @@ -93,7 +97,9 @@ mutable struct Feature <: ProtoType
fldname, fldval = nv
fldtype = symdict[fldname].jtyp
(fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
if fldval !== nothing
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
end
end
obj
end
Expand Down Expand Up @@ -132,7 +138,9 @@ mutable struct RouteNote <: ProtoType
fldname, fldval = nv
fldtype = symdict[fldname].jtyp
(fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
if fldval !== nothing
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
end
end
obj
end
Expand Down Expand Up @@ -171,7 +179,9 @@ mutable struct RouteSummary <: ProtoType
fldname, fldval = nv
fldtype = symdict[fldname].jtyp
(fldname in keys(symdict)) || error(string(typeof(obj), " has no field with name ", fldname))
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
if fldval !== nothing
values[fldname] = isa(fldval, fldtype) ? fldval : convert(fldtype, fldval)
end
end
obj
end
Expand Down