-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Split c files #75
Split c files #75
Conversation
Use consistent style in editor
These functions are used through all types
Using the macro pulls in a lot of dependencies that would slow down compile time for the importer that only needs the type declarations
And added a clang config file so the editor should pick the current style on foatting |
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 for taking the time to contribute! Some small thoughts on code structure.
interop.h
Outdated
typedef struct { | ||
ValuePtr value; | ||
RtnError error; | ||
} RtnValue; |
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.
Consider moving this to errors.h. It only exists to add an error to a value, so I think it belongs in the realm of error handling (and this file is small, with a vague scope.)
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.
Yeah, I had trouble placing this. I didn't think it so much of as an error, but more like converting the result to idiomatic go.
But I wouldn't mind putting it in errors. I didn't look too much at what the "errors.h" really contains, as extracting the errors file was mostly the result of, if I move A, I also need to move B.
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.
My problem is this file is too small and unfocused: no one will think of looking at this file to find RtnValue. A file that is about mapping error handling domains makes more sense to me. That said, it's not a strong opinion.
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've moved it to errors.h for now. Maybe a sensible place will reveal itself later :)
I don't have a strong opinion either.
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.
Btw, on "small files", there is also utils.h
/utils.cc
containing string copying functionality ...
Opinion on those?
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 think they're fine. Having one slush bucket is better than two, and probably unavoidable. :)
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.
Should we remove the almost empty file?
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.
Damn, I thought I did that.
Ahh, just realised I've made quite the mistake. I have this checked out under Code probably works as intended, as I've used it from my own project; which uses the "rewrite" feature of go mod to point to my own version. |
e7ec3a6
to
99e0822
Compare
I made the original comment:
But it appears that I did make a mistake, if I forward declare a
I can declare/define the functions as
Then the Go code is happy with
So I would be in favour of just removing the Wouldn't do it in this PR, just cleanup when working on new functionality. |
go vet complains of |
Ah thanks, just added them, was heading out the door, so didn't see what errors, were produced. Maybe I'll check up on it later, or tomorrow. |
Tests are happy now. This looks great! Just the question about removing |
b7d6fa8
to
69bb5b1
Compare
Thank you, GitHub email notification, for letting me know nothing happened. :) |
This is not a complete job yet, but paves a road forward.
There is some naming inconsistencies, that I've not done anything about. Example
Here the
IsolatePtr
references a v8 classHere the
ContextPtr
references a wrapper type in the v8go C++ code.And then there, a v8go C++ struct
ScriptCompilerCachedData
but aScriptCompilerCachedDataPtr
pointing to a v8 type.I don't think the
Ptr
is really useful here though. It seems that theXyzPtr
types are needed for Go code; it wouldn't compile when I just created a*v8Isolate
in Go alone - but I could have made a mistake.At any rate I would consider adopting a style like this:
As now it's clear what is a v8 type, and what is v8go type.
Avoid
using namespace
The header file has a
using namespace v8
. That is generally a not-so-good practice. Including a header file shouldn't cause namespaces to be included.Only include what's needed
The v8go.cc and .h file included the entire v8.h header file. This just includes what's necessary for the particular files; speeding up compilation
Use forward declarations
A type definition of structs/classes doesn't need to know the full definition of used types, just the size in memory. For classes and structs, I've created forward declarations to avoid having to include unnecessary header files.
Some non-trivial have been placed in
forward-declarations
, mostly as the C++ classes are non-trivial in their forward declarations.I think there might be tools that can automate header file dependency code, i.e., remove unnecessary includes, add necessary ones, create forward decl. But I have no experience using any of those, so I don't know how they would be set up, and what the are capable and incapable of.