-
Notifications
You must be signed in to change notification settings - Fork 490
Refactor wrapper.ts to improve maintainability #614
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
Conversation
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.
Unfortunately I did not manage to the through it all today so here's what I have so far.
Overall I did not find any real problems, mostly style/readability and places where naming could be clearer.
wrapper.ts
Outdated
if (callbacks) { | ||
assert(typeof callbacks === 'object', 'Invalid callback object specified.'); | ||
https.get(url, response => { | ||
if (response.statusCode > 299 || response.statusCode < 200) { |
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.
This is actually a behavior change. I mean, it looks like a good change, but still, this PR is supposed to be just a refactor. Can you put any behavior changes in separate commits so that they stand out?
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.
Ah the http codes, yeah I can convert it and add it again in another pr in the future.
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.
I mean, a separate commit is enough. Does not have to be a full-blown PR. It's just stuff that's easy to miss in a bigger refactor :)
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.
okay i'll add another commit at the end of this review to include it
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.
Marking this unresolved since the commit is not there yet.
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.
Ah yeah can do or another PR to keep it out, I will look to add this once we are fully happy with the other commits. I'm not a massive fan of this minimise commits flow when you can just squash commits during the merge which is why I left it out.
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.
I finally managed to get through it all.
I found two or three places that look like bugs. This indicates that we really don't have enough test coverage here.
Other than that, some comments about naming and overall structure. Some details need tweaking but I really like the final effect.
alloc: bindAlloc(solJson), | ||
license: bindLicense(solJson), | ||
version: bindVersion(solJson), | ||
reset: bindReset(solJson) |
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.
The current core
module is a bag of everything. At the same time it does not include some stuff that I'd consider to be the core functionality of a compiler - i.e. compilation.
- I don't think
license
andversion
really fit incore
. I'd put them in a separate module (maybecompiler-info
?) - Then
core
becomes more likeutils
orhelpers
. - Callbacks could really be in a module of their own. You already have them separated from compilation methods with headers.
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.
Can do but callbacks are not bindings they are directly related to the compiling and should stay related (imo), will make this kind of change.
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.
@cameel this creates a lot of additional implementation detail that adds more complexity than required. Taking those out results in passing another set of values deep into the callback code which is already complex.
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.
ok. I thought moving them would be easy but if it does introduce that much complexity then let's leave them as is.
I'll take a closer look when I'm back next week but overall this is not a deal breaker.
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.
So apart from callbacks there are still the first 2 points. core
really does not sound right to me here since the stuff in it is so peripheral. Maybe it would make more sense as memory
(containing alloc, reset, the string helpers) and info
(containing license, version, semver, etc.). Or something like that.
The only way it makes sense to me to call these core
is by saying they're all equal parts of libsolc.h
, which is true but still...
But anyway, at this point I just want to get this merged so that's just an optional suggestion. If you can adjust it easily, great, if not, we'll go with what it's already there anyway.
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.
I believe pulling it out was overly complicated since they would then depend on each other in some way. I will look again to see what can be improved, might be able to do something.
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.
I believe this still stands.
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.
I have checked the old code against the new one to ensure that every function is present and it seems fine.
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.
I left 3 comments but everything important has been addressed. I'm marking as approved since the review is done and we just need to finish discussing these small points and merge.
Also, please rebase on latest |
Hey, what is missing in this PR to be merged? Just the rebase on the latest master? It would be great to have this merged. |
Basically rechecking the 3 comments I mentioned and rebasing. We're pretty much done here. |
Then we need to rebase #615 on top of that and review. |
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.
Thanks! I think we can merge it now and move on to the PR that adds types.
Sounds good! I cannot merge it but ping me when its done and i'll rebase the next PR 🔥 |
Merged. |
Why?
This change works on refactoring out the wrapper.ts file to allow improved maintainability, extensibility with support of easy typing. The current implementation is one continuous function call which allocates all the bindings with hard to follow scoping.
Any bindings of methods have been split out into the
binding
directly, currently containing the core (anything not compiler related) and compiler related bound functions.Whats Next?
Since the wrapper is the main entry point for most consumers of the service, this should allow cleanly defined types to be exported with the package. Allowing language servers and IDEs to consume the types and expose them to the user for an improved experience.
This has been done here #615