-
Notifications
You must be signed in to change notification settings - Fork 21
RFC: Add macros for setting StructType #65
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
quinnj
left a comment
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 like this idea. Would you mind adding some tests in the test/runtests.jl file to ensure the codepaths are exercised? Probably don't need to test each type, but at least the various symbol/expr forms.
src/macros.jl
Outdated
| for struct_type in (:Struct, :Mutable, :CustomStruct, :OrderedStruct, :AbstractType, :DictType, :ArrayType, :StringType, :NumberType, :BoolType, :NullType) | ||
| @eval begin | ||
| @doc """ | ||
| @$($struct_type)(expr::Expr) |
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.
From the tests, it seems like we're over-interpolating here; maybe change to @$(Meta.quot($struct_type))
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 it's possibly to do with the macros being evaluated before the struct types exist - moving the include statement to the end of StructTypes.jl seems to work.
@$(Meta.quot($struct_type)) made the docs look a bit funny:
help?> StructTypes.@DictType
@:(StructTypes.DictType)(expr::Expr)
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, that makes sense. do you want to push your change then?
|
Changed the docs (it had |
Codecov Report
@@ Coverage Diff @@
## main #65 +/- ##
==========================================
+ Coverage 72.83% 73.53% +0.70%
==========================================
Files 1 2 +1
Lines 346 359 +13
==========================================
+ Hits 252 264 +12
- Misses 94 95 +1
Continue to review full report at Codecov.
|
Adds macros to define StructTypes, see #64
Example use:
Ideally they would be exported as well, to minimise how much typing was required.
If this seems something we would want I'll add tests and docs.