-
Notifications
You must be signed in to change notification settings - Fork 50
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
Code Generator produces messages with broken dependencies #28
Code Generator produces messages with broken dependencies #28
Conversation
This includes and supersedes #27 . |
Hi, @bkerley! @bmizerany and I spoke a week ago about maintainership, and we have transitioned Beefcake to the @protobuf-ruby group on GitHub. I would like to review your pull request, but it looks out of date. Can you rebase? |
|
||
task default: :test | ||
|
||
Rake::TestTask.new :test do |t| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HEAD does some of this now, so you'll definitely want to rebase.
Hey, so overall this looks OK. Would you be willing to include inline a before-and-after of the generated code or include them in Gist for review? I would like to compare this a bit more precisely. Without having the diff, I am curious, why not output the messages with a topological sort instead of defining the class specification a priori? |
This allows messages to refer to themselves without needing to be smart about inclusion order.
Just force-pushed the rebase, will generate before & after. |
https://gist.github.com/bkerley/6284225 contains before and after. The issue this branch fixes is at https://gist.github.com/bkerley/6284225#file-before-riak_kv-pb-rb-L221 |
Taking a look at the jruby failure on travis: https://travis-ci.org/protobuf-ruby/beefcake/jobs/10417342 |
@@ -165,6 +165,9 @@ def file!(file) | |||
puts "## Generated from #{file.name} for #{file.package}" | |||
|
|||
file.message_type.each do |mt| | |||
define! mt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So quick practical question: Why not use TSort (http://www.ruby-doc.org/stdlib-2.0/libdoc/tsort/rdoc/TSort.html) to sort the messages by the message types of their child fields? You'd emit less code to the user that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TSort doesn't cover the mutual recursion case, where two or more messages can refer to each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I did not know that was legal with Protocol Buffer definitions, and I don't think I've ever seen that before (past life as a Googler). Cool. That part looks fine, then.
Just a few open questions in https://github.com/protobuf-ruby/beefcake/pull/28/files. |
@@ -82,9 +82,10 @@ desired namespace. (i.e. App::Foo::Bar) | |||
|
|||
Source: | |||
|
|||
$ git clone git://github.com/bmizerany/beefcake | |||
$ git clone https://github.com/bmizerany/beefcake.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need to update this to github.com/protobuf-ruby/beefcake.
Almost ready for submission. Just take care of the last simple remarks, and we're good to merge. |
LGTM. Thank you for your work and patience and thoroughness! |
Code Generator produces messages with broken dependencies
This is part of the output of running the generator from 67f4894 against https://github.com/basho/riak_pb/blob/master/src/riak_kv.proto :
The issue is that
RpbContent.links
cannot be defined, because it depends on theRpbLink
class that hasn't been read yet.What I'll try and do this week is find a way to create all the classes up front, so they all exist when they try to get tagged in messages.