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

Improvements to generator of conversion methods. #7354

Merged
merged 1 commit into from Apr 27, 2015

Conversation

wojtek-t
Copy link
Member

  • generate conversion functions in alphabetical order
  • better handling of pointer arguments
  • some small refactoring

Part of #6800

cc @smarterclayton @lavalamp

@wojtek-t
Copy link
Member Author

@lavalamp you suggested adding a test to checking that functions registered via AddGeneratedConversionFunctions() weren't manually modified. I completely agree this is a good idea but I started thinking what's the best way to do it. This will be even harder as soon as we change those functions to be named and calling them one from another since they will need to be defined outside "AddGeneratedConversionFunctions()" method. Any suggestions on wht is the best way to do it? Do we want to explicitly compare the file as text with what would be generated? Thanks!

@lavalamp
Copy link
Member

@wojtek-t Yeah, I think auto-generated stuff has to be clearly demarcated in files such that that test can just be a direct comparison. This is also important for humans editing things, so they know to edit the source and not the autogenerated stuff.

return err
}
if err := writeLine(w, indent+1, "return err\n"); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Check out http://golang.org/pkg/go/format/#Source for auto-formatting of this code. Then you could ignore tabbing.

if err := writeLine(w, indent, ifStmt); err != nil {
return err
}
newFormat := "out.%s = new(%s)\n"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe if out.%s == nil { out.%s = new(%s) } \n ?

@lavalamp
Copy link
Member

LGTM -- comments are optional and can be addressed in a followup

lavalamp added a commit that referenced this pull request Apr 27, 2015
Improvements to generator of conversion methods.
@lavalamp lavalamp merged commit e0e83fa into kubernetes:master Apr 27, 2015
@wojtek-t wojtek-t deleted the conversion_improvements branch April 30, 2015 12:14
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

3 participants