-
Notifications
You must be signed in to change notification settings - Fork 28
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
add a C api for SBMLErrorLog #342
Conversation
src/sbml/SBMLErrorLog.cpp
Outdated
{ | ||
return static_cast<const SBMLError*>(*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.
this looks scary, is this really needed? Is it safe? because those could always be XMLErrors and not SBMLErrors, so when accessing them from the C API we'd be giving them bad pointers. It would be better to just use the get error function returning an XMLError and have a function to figure out whether an XMLError is an SBMLError (which would be clear from the error code)
I'm sure I could devise a way to make that static cast do bad things if needed. So let's think about this once again. (sorry)
src/sbml/SBMLErrorLog.cpp
Outdated
if (log == NULL) | ||
return NULL; | ||
|
||
return (const SBMLError_t*)(XMLErrorLog_getError((const XMLErrorLog_t*)(log), n)); |
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 we should still return a dynamic cast to an SBMLError, since the error returned might not be an SBMLError. At least we should have a test for this.
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 reverted my static casts
SBMLErrorLog_free(log); | ||
} | ||
END_TEST | ||
|
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 we need tests that test retrieving SBMLErrors when they are XMLErrors ensuring we don't garble ptrs.
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.
hello Sarah, I added some remarks, could you just verify that I'm totally wrong on those. thank you.
okay I changed the static cast and added test for the different types of error. I must admit I'm a little bit confused by the results |
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.
thank you for these changes, this looks great
Description
adds a c api for SBMLErrorLog
Motivation and Context
Fixes #329
Types of changes
Checklist:
Testing