Skip to content
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

Analyser/Generator: added some xxxAsString() methods #1131

Merged
merged 23 commits into from
Apr 26, 2023

Conversation

agarny
Copy link
Contributor

@agarny agarny commented Feb 20, 2023

Fixes #446.

src/analyserequation.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@hsorby hsorby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enumerations could probably all have there doxygen comments updated to the correct line reference.

src/analyser.cpp Show resolved Hide resolved
src/analyserequationast.cpp Show resolved Hide resolved
src/analyserexternalvariable.cpp Show resolved Hide resolved
src/api/libcellml/analyserequation.h Outdated Show resolved Hide resolved
src/enums.cpp Outdated Show resolved Hide resolved
nickerso
nickerso previously approved these changes Apr 5, 2023
Copy link
Contributor

@nickerso nickerso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is looking ok. The one concern I have is that the use of all the typeToString.at() will throw an exception if called with a non-existent type. I think we have previously agreed to avoid throwing exceptions - maybe? Should we either be protecting from throwing exceptions or documenting that they could happen?

Also fine with this going in as is and addressing this as part of that plan to test the API with null values...

@agarny
Copy link
Contributor Author

agarny commented Apr 5, 2023

I think this is looking ok. The one concern I have is that the use of all the typeToString.at() will throw an exception if called with a non-existent type. I think we have previously agreed to avoid throwing exceptions - maybe? Should we either be protecting from throwing exceptions or documenting that they could happen?

Those typeToString.at() calls are made within methods that take an enum class value as a parameter which is then used as a parameter to the at() method. So, we will always be fine.

@nickerso
Copy link
Contributor

nickerso commented Apr 5, 2023

I think this is looking ok. The one concern I have is that the use of all the typeToString.at() will throw an exception if called with a non-existent type. I think we have previously agreed to avoid throwing exceptions - maybe? Should we either be protecting from throwing exceptions or documenting that they could happen?

Those typeToString.at() calls are made within methods that take an enum class value as a parameter which is then used as a parameter to the at() method. So, we will always be fine.

doh! thanks. Is that enforced across to the Python bindings too?

@agarny
Copy link
Contributor Author

agarny commented Apr 5, 2023

I think this is looking ok. The one concern I have is that the use of all the typeToString.at() will throw an exception if called with a non-existent type. I think we have previously agreed to avoid throwing exceptions - maybe? Should we either be protecting from throwing exceptions or documenting that they could happen?
Those typeToString.at() calls are made within methods that take an enum class value as a parameter which is then used as a parameter to the at() method. So, we will always be fine.
doh! thanks. Is that enforced across to the Python bindings too?

Hmm, good question! I would guess that it isn't. I mean, enum class values are converted to integers in Python, right? So... anything could go there. @hsorby?

@hsorby
Copy link
Contributor

hsorby commented Apr 6, 2023

Yes, I think we have protections on some of the API for the bindings covering enumerations: see here

%typemap(in) libcellml::AnalyserEquationAst::Type (int val, int ecode) {
I think this should be added for these methods as well.

@agarny
Copy link
Contributor Author

agarny commented Apr 17, 2023

Yes, I think we have protections on some of the API for the bindings covering enumerations: see here

%typemap(in) libcellml::AnalyserEquationAst::Type (int val, int ecode) {

I think this should be added for these methods as well.

Ok, I believe I have added everything that is needed for our Python bindings. I have also checked for our JavaScript bindings and it looks like we are already all good for that one.

@agarny agarny requested a review from nickerso April 17, 2023 00:05
nickerso
nickerso previously approved these changes Apr 25, 2023
Copy link
Contributor

@hsorby hsorby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we don't test test our Python bindings but in the case of the typeAsString methods and their ilk I think we should test the extents in the Python bindings as this is something that we have added to the interface files to (hopefully) avoid segfaults.

@agarny
Copy link
Contributor Author

agarny commented Apr 25, 2023

I know we don't test test our Python bindings but in the case of the typeAsString methods and their ilk I think we should test the extents in the Python bindings as this is something that we have added to the interface files to (hopefully) avoid segfaults.

I believe it has already been done, not only for Python (e.g., https://github.com/cellml/libcellml/pull/1131/files#diff-6217397c5913cb67ab08329d9d5b36e17a6a2367ac49c585ae580aa1fd11c328), but also for JavaScript (e.g., https://github.com/cellml/libcellml/pull/1131/files#diff-b49b859ee2ff441946db1f6ea8d135398596fccd8b5b023b6811c7e37b253535)... or am I missing something?

Note that we don't need to test this in JavaScript since its behaviour is the same as in C++ (we need to pass an enum class value, not an integer value as in Python).
src/units.cpp Outdated Show resolved Hide resolved
src/units.cpp Outdated Show resolved Hide resolved
nickerso
nickerso previously approved these changes Apr 26, 2023
@hsorby hsorby merged commit 61b6243 into cellml:main Apr 26, 2023
@agarny agarny deleted the issue446 branch April 26, 2023 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Name or map function for generator modelType enums?
3 participants