Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a primitive field mapping from symbol to field class #170

Merged
merged 4 commits into from
Feb 17, 2014

Conversation

localshred
Copy link
Contributor

Generate “prettier” message code that uses symbols for all the
primitive types in the definition.

 optional ::Protobuf::Field::StringField, :bar, 1 end

 optional :string, :foo, 1 end

You can mostly ignore the Rakefile and *.pb.rb file changes, the relevant changes are in lib/protobuf/field.rb and lib/protobuf/generators/field_generator.rb.

Allows us to generate “prettier” message code that use symbols for all
the primitive types in the definition.

```ruby
# old
class Foo
  optional ::Protobuf::Field::StringField, :bar, 1
end

# new
class Bar
  optional :string, :foo, 1
end
```
@localshred
Copy link
Contributor Author

/cc @liveh2o @abrandoned @devin-c

proto_path = ::File.expand_path('../spec/support/', __FILE__)
cmd = %Q{protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{proto_path} -I #{proto_path} #{File.join(proto_path, '**', '*.proto')}}
puts cmd
exec cmd
end

desc "Compile spec protos in spec/supprt/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the description got left behind from the copy/paste.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, updating...

@liveh2o
Copy link
Contributor

liveh2o commented Feb 15, 2014

Other than the task description, I think this looks good. Nice to have prettier output, but I also wonder what additional functionality may be gleaned from the new primitive mapping. 👍

@abrandoned
Copy link
Contributor

love the new syntax, I think long term benefit could be multiple encoders/decoders thrift/message pack /avro could all come of a unified ddl

localshred added a commit that referenced this pull request Feb 17, 2014
Use a primitive field mapping from symbol to field class
@localshred localshred merged commit e6f1685 into master Feb 17, 2014
@localshred localshred deleted the bj/symbol-fields branch February 17, 2014 19:57
@localshred localshred added this to the v3.x milestone Feb 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants