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
17 changes: 0 additions & 17 deletions _examples/smoke/example.gen.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@

















// smoke v1.0.0 6dc82371b24d044c3b3e2bd4cf5d92af46788fff
// --
// Code generated by webrpc-gen@v0.37.1 with .. generator. DO NOT EDIT.
Expand Down
4 changes: 2 additions & 2 deletions impl.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{{- $prefix := .Prefix -}}
{{- $encodeReachable := dict -}}
{{- $decodeReachable := dict -}}
{{ template "collectStructCodecReachability" dict "Types" .Types "Services" .Services "EncodeReachable" $encodeReachable "DecodeReachable" $decodeReachable }}
{{ template "implPreamble" . }}
{{- template "collectStructCodecReachability" dict "Types" .Types "Services" .Services "EncodeReachable" $encodeReachable "DecodeReachable" $decodeReachable -}}
{{- template "implPreamble" . }}
{{ template "implTransport" . }}

{{- range $_, $type := .Types }}
Expand Down
12 changes: 6 additions & 6 deletions implCodecReachability.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
{{- $types := .Types -}}
{{- $reachable := .Reachable -}}
{{- if isMapType $type }}
{{ template "markStructCodecReachability" dict "Type" (mapValueType $type) "Types" $types "Reachable" $reachable }}
{{- template "markStructCodecReachability" dict "Type" (mapValueType $type) "Types" $types "Reachable" $reachable -}}
{{- else if isListType $type }}
{{ template "markStructCodecReachability" dict "Type" (listElemType $type) "Types" $types "Reachable" $reachable }}
{{- template "markStructCodecReachability" dict "Type" (listElemType $type) "Types" $types "Reachable" $reachable -}}
{{- else if isCoreType $type }}
{{- else if isEnumType $type }}
{{- else if and (hasField $type "Alias") $type.Alias }}
{{ template "markStructCodecReachability" dict "Type" $type.Alias.Type.Type "Types" $types "Reachable" $reachable }}
{{- template "markStructCodecReachability" dict "Type" $type.Alias.Type.Type "Types" $types "Reachable" $reachable -}}
{{- else if isStructType $type }}
{{- $typeName := toString $type -}}
{{- if not (exists $reachable $typeName) }}
{{- $_ := set $reachable $typeName true -}}
{{- range $_, $candidate := $types }}
{{- if and (isStructType $candidate) (eq $candidate.Name $typeName) }}
{{- range $_, $field := $candidate.Fields }}
{{ template "markStructCodecReachability" dict "Type" $field.Type "Types" $types "Reachable" $reachable }}
{{- template "markStructCodecReachability" dict "Type" $field.Type "Types" $types "Reachable" $reachable -}}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -32,10 +32,10 @@
{{- range $_, $service := .Services }}
{{- range $_, $method := $service.Methods }}
{{- range $_, $input := $method.Inputs }}
{{ template "markStructCodecReachability" dict "Type" $input.Type "Types" $types "Reachable" $encodeReachable }}
{{- template "markStructCodecReachability" dict "Type" $input.Type "Types" $types "Reachable" $encodeReachable -}}
{{- end }}
{{- range $_, $output := $method.Outputs }}
{{ template "markStructCodecReachability" dict "Type" $output.Type "Types" $types "Reachable" $decodeReachable }}
{{- template "markStructCodecReachability" dict "Type" $output.Type "Types" $types "Reachable" $decodeReachable -}}
{{- end }}
{{- end }}
{{- end }}
Expand Down
3 changes: 1 addition & 2 deletions main.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- define "main" -}}

{{- $opts := dict -}}
{{- $defaultPrefix := (snakeCase .SchemaName) -}}
{{- $emitClient := (ternary (eq (default .Opts.client "true") "false") false true) -}}
Expand Down Expand Up @@ -38,7 +37,7 @@

{{- $prefix := $opts.prefix -}}
{{- if eq $opts.emit "impl" -}}
{{ template "impl" dict "Prefix" $prefix "Header" $opts.header "SchemaName" .SchemaName "SchemaVersion" .SchemaVersion "SchemaHash" .SchemaHash "BasePath" (default (and (hasField . "BasePath") .BasePath) "/rpc/") "WebrpcGenVersion" .WebrpcGenVersion "WebrpcTarget" .WebrpcTarget "WebrpcGenCommand" .WebrpcGenCommand "Types" .Types "Services" .Services "Errors" .Errors "WebrpcErrors" .WebrpcErrors "Opts" $opts "Client" $emitClient }}
{{- template "impl" dict "Prefix" $prefix "Header" $opts.header "SchemaName" .SchemaName "SchemaVersion" .SchemaVersion "SchemaHash" .SchemaHash "BasePath" (default (and (hasField . "BasePath") .BasePath) "/rpc/") "WebrpcGenVersion" .WebrpcGenVersion "WebrpcTarget" .WebrpcTarget "WebrpcGenCommand" .WebrpcGenCommand "Types" .Types "Services" .Services "Errors" .Errors "WebrpcErrors" .WebrpcErrors "Opts" $opts "Client" $emitClient -}}
{{- else -}}
{{- $guard := printf "%s_%s_%s_H" (toUpper (snakeCase .SchemaName)) (toUpper (snakeCase $prefix)) (toUpper $opts.emit) -}}
#ifndef {{$guard}}
Expand Down
Loading