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

Support optional generation #7

Merged
merged 6 commits into from Apr 27, 2019

Conversation

Projects
None yet
3 participants
@ice1000
Copy link
Member

commented Apr 19, 2019

Support generating only selected family of functions.

ice1000 added some commits Apr 19, 2019

Bump dependency versions, add bitflags as dependency
Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>
Start using bitflags
Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>
Support optional generation
Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>

@ice1000 ice1000 added the enhancement label Apr 19, 2019

@ice1000 ice1000 requested a review from nrc Apr 19, 2019

Ooops. `new_` is missing.
Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>
@ice1000

This comment has been minimized.

Copy link
Member Author

commented Apr 19, 2019

This is required by pingcap/raft-rs#218

@ice1000

This comment has been minimized.

Copy link
Member Author

commented Apr 19, 2019

QAQ

pub enum GenOpt {
All,
NoImplMessage,
bitflags! {

This comment has been minimized.

Copy link
@hicqu

hicqu Apr 23, 2019

I doubt that whether we really need so many options or not. I only like MSG, CLR, HAS, and TKE in person. NEW can be replaced with Default, and GET, SET and MUT are useless because we can touch the internal fields directly.

This comment has been minimized.

Copy link
@ice1000

ice1000 Apr 23, 2019

Author Member

The process of eliminating wrapper usages should be step by step and this (relatively) fine grained config can help us do that.

This comment has been minimized.

Copy link
@hicqu

hicqu Apr 24, 2019

Or can we merge these 3 as one option?

This comment has been minimized.

Copy link
@ice1000

ice1000 Apr 24, 2019

Author Member

@hicqu I guess you've missed the point of this PR. What I was trying to do is to introduce a mechanism which can gradually reduce the wrapper functions. The ultimate goal is passing a GenOpt::empty() to the wrapper generator. Currently we're generating all of them so we can quickly launch prost support and my plan is to replace all usages of the generated wrappers with direct access. These options allow me to eliminate the generated wrappers step by step. That's all. 😉

This comment has been minimized.

Copy link
@hicqu

hicqu Apr 24, 2019

So after all wrappers are removed, should we remove these options also?

This comment has been minimized.

Copy link
@ice1000

ice1000 Apr 24, 2019

Author Member

We can! And I believe we're supposed to do so.

@hicqu

This comment has been minimized.

Copy link

commented Apr 23, 2019

@nrc PTAL. kvproto is blocked on raft-rs, and raft-rs is blocked on here.

@nrc
Copy link
Collaborator

left a comment

Looks good, a few small comments inline

Show resolved Hide resolved src/lib.rs Outdated
Show resolved Hide resolved src/wrapper.rs
Show resolved Hide resolved src/wrapper.rs Outdated
Show resolved Hide resolved src/wrapper.rs Outdated
Address comments: renames, fix `use`, add more bitflags
Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>
@ice1000

This comment has been minimized.

Copy link
Member Author

commented Apr 26, 2019

@nrc something else to consider:

We may need to provide an option that "generates getters that are not of primitive types".

@ice1000

This comment has been minimized.

Copy link
Member Author

commented Apr 26, 2019

Because for non-primitive types, they become Option<Bla>, where we're supposed to provide a getter that uses a default value for them.

@ice1000

This comment has been minimized.

Copy link
Member Author

commented Apr 26, 2019

I start doubting the idea of eliminating all getters. I'm here to propose another design of this library (unrelated to this PR):

  • Generate non-trivial getters (which unwrap_or_else for you)
  • Generate trivial getters with #[deprecated]
  • Provide options to eliminate deprecated stuffs

PTAL @nrc

Publicize `rustfmt` because we may want to fmt the mod files
Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>
@nrc

nrc approved these changes Apr 27, 2019

@nrc nrc merged commit 643897c into master Apr 27, 2019

1 check passed

DCO All commits are signed off!
Details

@ice1000 ice1000 deleted the bitflags branch Apr 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.