-
Notifications
You must be signed in to change notification settings - Fork 49
Refactor Parser #163
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 Parser #163
Conversation
| return PARSER_INCOMPLETE; | ||
| } | ||
|
|
||
| parser_return_state_t parse_sever_settings_message(snapcast_custom_parser_t *parser, |
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 could put all those variables passed to the functions in a struct/union combination.
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.
Yes! I will do this, once the parser is simplified. I think I will be able to remove a lot of parameters corresponding to internal parser state first.
|
Before you continue your effort maybe we should check if netconn api is really the best thing to use. There have been some packet delivery issues on my last tests and I am uncertain where this comes from. Also espressif says netconn is less resource intensive but when asking chatGPT I get this for an answer So I am abit confused now and I think a comparison of the two should be done by logging max heap usage while reception. Maybe we can integrate this into http_task and just drop all the data and do the same using sockets |
|
I’ve significantly reduced the number of parameters passed to These values now live in much smaller scopes: either directly inside Strongly reducing the parameter count further would likely mean grouping values with little semantic connection into a shared struct. I’m not sure that would improve readability or maintainability. But I may also be missing what kind of refactoring you have in mind. If you’d like me to continue in this direction, a concrete example of the struct or grouping you’re thinking of would really help. Let me know if the current state works for you. If so, I’ll resolve the conflicts and get things wrapped up 🙂 |
|
Thank you. Hopefully I'll find some time to review soon. Maybe someone else will jump in sooner? |
|
I just had a look at the conflicts and it's ... a lot. Maybe it makes sense to postpone the review until the conflicts are resolved? I'm not sure. But I guess I'll already start working toward resolving the conflicts, because this will only get worse the more |
9d6fc4e to
49bf600
Compare
|
I finally managed to resolve all of the conflicts! 🎉 |
|
I had no time to look into details, but I like the structure a lot and a quick test was running fine. @CarlosDerSeher I think it would be great if we could move forward because all the PRs or planned PRs would benefit from not modifying the same main.c file. #174 wants to wait for this, I also wait with further work. And #195 again adds a lot of modifications, that would otherwise go the the connection_manager I guess. |
|
Oh didn't realize this was ready :) nice |
|
Great, and just today I merged some other stuff :( hopefully this isn't so much work to resolve |
It's resolved again :) |
e234e51
into
CarlosDerSeher:refactor_parser
Hi!
This PR aims to improve the readability of
main.cby separating parsing logic from message handling.Although the code is already separated, it's not perfect, and there is still work to be done. There are, for example, too many variables being passed in function calls for my taste.
I'm planning to write a
read_bytefunction that the parser can call. If would fetch data from the network when the buffer is empty. This would allow us to eliminate theswitch/caseand make many variables locally scoped. I would use error codes to detect whether a reset (corresponding to the outermost while loop of the ´http_get_task`) is necessary.It might also make sense to further modularize the message-handling side (e.g., splitting out time sync, codecs, etc.), but that can easily be done in a later PR.