Add astGetKeyMap protected method to Object - #55
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #55 +/- ##
==========================================
+ Coverage 61.13% 61.17% +0.04%
==========================================
Files 83 83
Lines 96370 96395 +25
Branches 30543 30551 +8
==========================================
+ Hits 58913 58973 +60
+ Misses 21411 21358 -53
- Partials 16046 16064 +18 ☔ View full report in Codecov by Harness. |
|
A few points about your code changes:
Otherwise, it all looks good. |
|
Huh, to my mind returning a borrowed reference seemed to make more sense / be more convenient, so I documented it as such. But if it would be inconsistent with how literally everything else works I'm happy to change that. Not sure why a subclass would want to extend this--maybe to provide a default, non-empty keymap? Would be easy enough to change later if needed. I'll look at GetObjSize and ManageLock. |
|
Should be better now
The more I dig into the internals of how this library works the more impressed I am with how well it's designed; it's really a pleasure to work with. Making each Object hierarchy uniquely owned by a single thread is a good call. |
|
Oh, forgot to mention, I also added I was for a while scratching my head about why codecov's report includes all sources, even those that aren't included in the uploaded lcov.info. Turns out codecov's tool actually runs over the entire build directory automatically, extracting any coverage information it can find, including raw gcov outputs, and incorporate that. That can be disabled by passing it But by |
|
Updated to include an I'm still having some doubts as to whether it's even the right call to include this in the |
|
Your call. The default assumption would be that it is dumped, along with every other aspect of the Object. So if you decide not to include it in the dump, then it should be very clearly documented somewhere. |
|
Right. I think that's why it's best to keep for now. |
It wasn't easy to follow what exactly was being tested here, so I split each logical functionality being tested into separate unit tests, in preparation to add more.
This is useful for checking coverage of the tests themselves locally (previously they were excluded from the lcov report). coverage analysis on tests is good to make sure the tests are being run as expected, don't have dead code, etc. I added some LCOV_EXCL_LINE in testobject.c for the astError calls that *should* never be reached under normal operating, boosting the overall coverage to 99%
- astGetKeyMap returns a new reference now via astClone, not a borrowed reference, so caller has to astAnnul - account for this->key_map in GetObjSize and ManageLock - in the tests, realized I should use astSame to compare object identity, rather than direct pointer comparison; while the latter works when only testing the internal API that's an implementation detail--if we later want to change this to a public API the test will still have the correct semantics
This allows testing if an Object already has an associated KeyMap without implicitly creating one as astGetKeyMap does.
|
Is this OK to merge? I've also tried it out a bit in #66 and it will help with some other transforms I'm adding support for. |
|
(P.S. @timj I saw you gave me merge permissions anyways, but I want to make sure not to step on any toes) |
|
Merging is okay with me |
Resolves #54. My motivation here is primarily for use in yamlchan.c to make round-tripping certain transforms easier.
Currently it uses a lot of structural pattern-matching (e.g.
FindSphericalCartesian) to reconstruct the appropriate ASDF transforms from a slice of the mapping list. This code is still useful and necessary -- e.g. for hand-constructed astMapping, or one read from another source, one will still need to figure out the most appropriate way to serialize it back to ASDF.But for the case of deserializing from ASDF it will also be very useful to maintain additional information on the deserialized mappings for accurate round-tripping without having to go down the full
Find<Foo>path. This idea is already used, to an extent, by theKeyMapattached to some mappings viaastSetProxy, but that proves not as useful since the proxy object can't survive copying, per the discussion in #54. So this would be used to replace that.Had started out with trying to reorganize
ast_tester/testobject.cin anticipation of adding more unit tests for this, but then realized since it's a protected interface it needs to be compiled withastCLASSdefined, so ended up having to put the tests for this in a separate test program anyways.