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

Fix NamedType generation in MATLAB codegen #193

Merged
merged 4 commits into from
Dec 13, 2024
Merged

Conversation

naegelejd
Copy link
Contributor

This PR fixes a bug in MATLAB codegen that was found when implementing tools in MATLAB for the PETSIRD model.

Previously, most NamedTypes were implemented in MATLAB as a function returning an instance of the underlying type, since MATLAB does not support type aliasing. This approach doesn't work when attempting to create vectors or arrays of the NamedType. The PETSIRD model contains vectors of aliased Record types, which uncovered the bug.

Now, we no longer generate any MATLAB code for NamedTypes that alias strings, vectors, or arrays. Records, unions, and optional NamedTypes are implemented using subclassing. Yardl maps are now implemented as a MATLAB yardl.Map class, which wraps the dictionary type.

@naegelejd naegelejd requested a review from johnstairs December 12, 2024 19:32
Copy link
Member

@johnstairs johnstairs left a comment

Choose a reason for hiding this comment

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

Was matlab/test/test_aliases.yardl meant to be included?

@naegelejd naegelejd merged commit 8699221 into main Dec 13, 2024
14 checks passed
@naegelejd naegelejd deleted the fix-matlab-aliases branch December 13, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants