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

Code Generator produces messages with broken dependencies #28

Merged
merged 8 commits into from
Aug 23, 2013

Conversation

bkerley
Copy link
Member

@bkerley bkerley commented Jul 16, 2013

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 :

class RpbContent
  include Beefcake::Message


  required :value, :bytes, 1
  optional :content_type, :bytes, 2
  optional :charset, :bytes, 3
  optional :content_encoding, :bytes, 4
  optional :vtag, :bytes, 5
  repeated :links, RpbLink, 6
  optional :last_mod, :uint32, 7
  optional :last_mod_usecs, :uint32, 8
  repeated :usermeta, RpbPair, 9
  repeated :indexes, RpbPair, 10
  optional :deleted, :bool, 11

end

class RpbLink
  include Beefcake::Message


  optional :bucket, :bytes, 1
  optional :key, :bytes, 2
  optional :tag, :bytes, 3

end

The issue is that RpbContent.links cannot be defined, because it depends on the RpbLink 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.

@bkerley
Copy link
Member Author

bkerley commented Jul 16, 2013

This includes and supersedes #27 .

@matttproud
Copy link
Member

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|
Copy link
Member

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.

@matttproud
Copy link
Member

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?

@bkerley
Copy link
Member Author

bkerley commented Aug 20, 2013

Just force-pushed the rebase, will generate before & after.

@bkerley
Copy link
Member Author

bkerley commented Aug 20, 2013

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

@bkerley
Copy link
Member Author

bkerley commented Aug 20, 2013

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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

@matttproud
Copy link
Member

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
Copy link
Member

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.

@matttproud
Copy link
Member

Almost ready for submission. Just take care of the last simple remarks, and we're good to merge.

@ghost ghost assigned matttproud Aug 23, 2013
@matttproud
Copy link
Member

LGTM. Thank you for your work and patience and thoroughness!

matttproud added a commit that referenced this pull request Aug 23, 2013
Code Generator produces messages with broken dependencies
@matttproud matttproud merged commit ec102f8 into protobuf-ruby:master Aug 23, 2013
@bkerley bkerley mentioned this pull request Aug 26, 2013
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.

None yet

2 participants