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

Refactor the input parsing of event_enums!

Merged
merged 12 commits into from Jul 13, 2020

Conversation

DevinR528
Copy link
Member

@DevinR528 DevinR528 commented Jul 11, 2020

Rename name -> kind and parse input as EventKind. EventKind will only parse for valid event kinds to guard against bad input.

DevinR528 added 2 commits Jul 11, 2020
Rename name -> kind and parse input as EventKind. EventKind will only
parse for valid event kinds to guard against bad input.
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
@DevinR528
Copy link
Member Author

DevinR528 commented Jul 12, 2020

I'm still kinda hoping to get rid of the string checks in the "helper" functions (like in accessor_methods). I'll look it over in the morning and comment again either way (if I figure something out or not).

ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
@DevinR528
Copy link
Member Author

DevinR528 commented Jul 12, 2020

I'll check moving variants, I think that would work good! Should have a commit for it in a few hours.

ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved

const PREV_CONTENT_KIND: &[&str] = &[ANY_STATE_EVENT, ANY_SYNC_STATE_EVENT];
fn state_key_kind(name: &EventKind, _var: &EventKindVariation) -> bool {
Copy link
Member

@jplatte jplatte Jul 12, 2020

Choose a reason for hiding this comment

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

You could inline a bunch of these that are only used once, as closures. (or is there some specific reason you didn't?)

Copy link
Member Author

@DevinR528 DevinR528 Jul 13, 2020

Choose a reason for hiding this comment

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

Size and readability but now I think they may be sort enough. I'll commit what I have then inline them so we have a before and after.

@jplatte
Copy link
Member

jplatte commented Jul 13, 2020

Just verified that room_event_kind and event_id_kind should be the same, and the previous arrays for those were also identical (modulo order).

ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
ruma-events-macros/src/event_enum.rs Outdated Show resolved Hide resolved
@jplatte jplatte merged commit 1db4898 into ruma:master Jul 13, 2020
3 checks passed
@DevinR528 DevinR528 deleted the refactor-event-macros branch May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants