-
Notifications
You must be signed in to change notification settings - Fork 8
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
Feature/c api #57
Feature/c api #57
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #57 +/- ##
===========================================
+ Coverage 61.31% 62.67% +1.35%
===========================================
Files 102 106 +4
Lines 6414 6725 +311
Branches 611 634 +23
===========================================
+ Hits 3933 4215 +282
- Misses 2481 2510 +29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Like the changes. Code and Documentation was extraordinarily clean. I was a bit nitpicky. Bear with me in case some of my suggestions are not compatible with modern C; it has been a while since I programmed in C ;)
src/metkit/api/metkit_c.cc
Outdated
/// @comment: (maby) | ||
/// Not sure if there is much value in having a param iterator. We could just return an array of | ||
/// strings (char**) using metkit_marsrequest_params. | ||
/// I think we should metkit_paramiterator_t. |
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.
Here the comment is lacking some words. Do this need to be addressed before merging?
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.
a todo left for me by me
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 need an extra test where you use the API and compile the test with a C compiler
src/metkit/api/metkit_c.h
Outdated
* @param it RequestIterator instance | ||
* @return int Error code | ||
*/ | ||
int metkit_requestiterator_next(metkit_requestiterator_t* 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.
I think this would make for a nicer API if we could use it like this:
while((res = metkit_paramiterator_next(it))) {
//...
}
Ofc this would only work if the iteration cannot create errors. But return a nullptr on end of iteration makes for a more natural api imo.
/// Not sure if there is much value in having a param iterator. We could just return an array of | ||
/// strings (char**) using metkit_marsrequest_params. | ||
/// I think we should metkit_paramiterator_t. | ||
struct metkit_paramiterator_t { |
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.
Lifetimes of returned values in this iterator differ from the metkit_requestiterator_t
iterator. For itself the lifetime is ok (if documented) but a subtle difference in lifetime handling with both types imply symmetrical behavior is a nasty trap. metkit_requestiterator_t
result lifetimes exceed the iterator due to the move out of the iterator, while the char*
from this iterator dangle as soon as the iterator is freed.
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 initially resolved this by simply getting rid of the paramiterator. But it turns out it's not so straight forward as the C++ marsrequest object does not provide a nice way to iterate over the params so I need to revisit this.
Maybe we should rewrite test_metkit_c.cc in C? For the time being I'll add a simple test that at least uses a C compiler |
Re: error handling, if we're going to do similar across the stack, it might make sense to centralise this somewhere (eckit). All of the caught exceptions are in fact eckit::exceptions |
Note: This may not be what a user expects when using the C APIs. |
src/metkit/CMakeLists.txt
Outdated
@@ -4,7 +4,7 @@ ecbuild_generate_config_headers( DESTINATION ${INSTALL_INCLUDE_DIR}/metkit ) | |||
|
|||
configure_file( metkit_config.h.in metkit_config.h ) | |||
configure_file( metkit_version.h.in metkit_version.h ) | |||
configure_file( metkit_version.cc.in metkit_version.cc ) | |||
configure_file( metkit_version.c.in ${CMAKE_CURRENT_BINARY_DIR}/metkit_version.c ) |
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 doesn't look right.
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.
Removed the .c configuration
No description provided.