Skip to content

Commit 7d833c1

Browse files
authored
CPP: modify package namespace to split on dot (#838)
Fixing C++ namespace to only use dot-notation splitting. For example, a proto that is in a package: `my_project` will use the same C++ namespace, avoiding the conversion to `my::project` as is done prior to this PR. Also updated protoc-gen-star to v2.0.4 @496ad1ac90a4 (ability to use `SplitOnDot`) using: `go get github.com/lyft/protoc-gen-star/v2@496ad1ac90a4` Fixes #822 --------- Signed-off-by: Adi Suissa-Peleg <[email protected]>
1 parent 03a680d commit 7d833c1

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

dependencies.bzl

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ def go_third_party():
220220
go_repository(
221221
name = "com_github_lyft_protoc_gen_star_v2",
222222
importpath = "github.com/lyft/protoc-gen-star/v2",
223-
sum = "h1:/3+/2sWyXeMLzKd1bX+ixWKgEMsULrIivpDsuaF441o=",
224-
version = "v2.0.3",
223+
sum = "h1:sIXJOMrYnQZJu7OB7ANSF4MYri2fTEGIsRLz6LwI4xE=",
224+
version = "v2.0.4-0.20230330145011-496ad1ac90a4",
225225
)
226226
go_repository(
227227
name = "com_github_pkg_errors",

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.19
44

55
require (
66
github.com/iancoleman/strcase v0.3.0
7-
github.com/lyft/protoc-gen-star/v2 v2.0.3
7+
github.com/lyft/protoc-gen-star/v2 v2.0.4-0.20230330145011-496ad1ac90a4
88
golang.org/x/net v0.20.0
99
google.golang.org/protobuf v1.32.0
1010
)

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
125125
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
126126
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
127127
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
128-
github.com/lyft/protoc-gen-star/v2 v2.0.3 h1:/3+/2sWyXeMLzKd1bX+ixWKgEMsULrIivpDsuaF441o=
129-
github.com/lyft/protoc-gen-star/v2 v2.0.3/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk=
128+
github.com/lyft/protoc-gen-star/v2 v2.0.4-0.20230330145011-496ad1ac90a4 h1:sIXJOMrYnQZJu7OB7ANSF4MYri2fTEGIsRLz6LwI4xE=
129+
github.com/lyft/protoc-gen-star/v2 v2.0.4-0.20230330145011-496ad1ac90a4/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk=
130130
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
131131
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
132132
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

templates/cc/file.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ pgv::Validator<{{ class . }}> {{ staticVarName . }}(static_cast<bool(*)(const {{
3434
} // namespace validate
3535
} // namespace pgv
3636
37-
{{ range .Package.ProtoName.Split }}
37+
{{ range .Package.ProtoName.SplitOnDot }}
3838
namespace {{ . }} {
3939
{{- end }}
4040
4141
{{ range .AllMessages }}
4242
{{- template "msg" . }}
4343
{{ end }}
4444
45-
{{ range .Package.ProtoName.Split -}}
45+
{{ range .Package.ProtoName.SplitOnDot -}}
4646
} // namespace
4747
{{ end }}
4848
`
@@ -62,7 +62,7 @@ const headerFileTpl = `// Code generated by protoc-gen-validate
6262
#include "validate/validate.h"
6363
#include "{{ output .File ".h" }}"
6464
65-
{{ range .Package.ProtoName.Split }}
65+
{{ range .Package.ProtoName.SplitOnDot }}
6666
namespace {{ . }} {
6767
{{- end }}
6868
@@ -72,7 +72,7 @@ using std::string;
7272
{{- template "decl" . }}
7373
{{ end }}
7474
75-
{{ range .Package.ProtoName.Split -}}
75+
{{ range .Package.ProtoName.SplitOnDot -}}
7676
} // namespace
7777
{{ end }}
7878

templates/cc/register.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (fns CCFuncs) className(ent childEntity) string {
163163
}
164164

165165
func (fns CCFuncs) packageName(msg pgs.Entity) string {
166-
return "::" + strings.Join(msg.Package().ProtoName().Split(), "::")
166+
return "::" + strings.Join(msg.Package().ProtoName().SplitOnDot(), "::")
167167
}
168168

169169
func (fns CCFuncs) quote(s interface {

templates/ccnop/file.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const headerFileTpl = `// Code generated by protoc-gen-validate
1111
#include "validate/validate.h"
1212
#include "{{ output .File ".h" }}"
1313
14-
{{ range .Package.ProtoName.Split }}
14+
{{ range .Package.ProtoName.SplitOnDot }}
1515
namespace {{ . }} {
1616
{{- end }}
1717
@@ -21,7 +21,7 @@ using std::string;
2121
extern inline bool Validate(__attribute__((unused)) const {{ class . }}& m, __attribute__((unused)) pgv::ValidationMsg* err) { return true; }
2222
{{ end }}
2323
24-
{{ range .Package.ProtoName.Split -}}
24+
{{ range .Package.ProtoName.SplitOnDot -}}
2525
} // namespace
2626
{{ end }}
2727

0 commit comments

Comments
 (0)