Huangyan9188 / gogoprotobuf

Automatically exported from code.google.com/p/gogoprotobuf
Other
0 stars 0 forks source link

support for option marshaler / marshaler_all for proto files with-dashes-in-them. #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hey.

> What steps will reproduce the problem?
1. create a proto file like

package mypackage;
import "code.google.com/p/gogoprotobuf/gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true;

message test {}

2. save it with name like my-package.proto (note the dash in the name)
3. run protoc --gogo_out=. -I$GOROOT/src -I. my-package.proto

> What is the expected output? What do you see instead?

You'll get an error like:

2014/05/29 20:03:07 protoc-gen-gogo: error:bad Go source code was generated: 
71:21: expected '(', found '-' (and 2 more errors)

What version of the product are you using? On what operating system?
- latest gogoprotobuf master branch (fb9da01)
- go version go1.2 linux/amd64
- Linux antoxa-suse.site 3.7.10-1.16-desktop #1 SMP PREEMPT Fri May 31 20:21:23 
UTC 2013 (97c14ba) x86_64 x86_64 x86_64 GNU/Linux

Please provide any additional information below.
i've narrowed it down to
func (p *marshalto) Generate(file *generator.FileDescriptor) {
...
p.localName = generator.FileName(file)

which transforms filename into camel cased name to use for function names.
camel casing handles underscores fine, but not dashes, and you get function 
names like "encodeVarintMy-package".

Naive patch - attached.

Original issue reported on code.google.com by anton.po...@gmail.com on 29 May 2014 at 4:14

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision c0f910cdcde7.

Original comment by awalterschulze on 30 May 2014 at 9:32

GoogleCodeExporter commented 9 years ago
Thank you very much.
I have added your fix with a test.

https://code.google.com/p/gogoprotobuf/source/detail?r=c0f910cdcde7b484263f20880
df1b3aff387305a

Original comment by awalterschulze on 30 May 2014 at 9:32