This repository has been archived by the owner on Jan 29, 2025. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[msl-out] wrap arrays in structs so that they can be returned by functions #764
[msl-out] wrap arrays in structs so that they can be returned by functions #764
Changes from all commits
605febe
fdce46b
0b376fa
68d757d
749eb59
5c0336a
1daaaa0
39fc8b8
1c3a2a9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
wait, so here we can't just do
_tmp.gl_ClipDistance1
for the last argument?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.
Nope, unfortunately not. Not
gl_ClipDistance1.inner
either.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.
hmm, I'm concerned now, a little bit. So when we are initializing the I/O struct, we can't just pass
_tmp.gl_ClipDistance1
because it's an array. But how would this work in other places? I.e. if you have a user function returning a user struct, then passing{ xxx.inner[0], xxx.inner[1] }
would just fail horribly, since the only field of the target struct isinner
.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.
Afaik, only having a single pair of those
{
brackets when constructing a struct is okay if it only has one field. I think more testing would be nice, but I haven't found a (trivial) example that this breaks. Something like the following, for example, is fine:->
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 mean, specifically for arrays.
My understanding is that this PR right now is not going to handle this. Ideally, we'd want it to generate something like
This will fail because the produced
Foo
would be declared with theinner
in it, but thereturn
code doesn't use 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.
Ok, I don't understand how
type1 {1.0, 2.0, 3.0}
part works :(type1
is a structure with 1 element. So shouldn't it yell at us for providing 3 elements instead of 1?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.
Yeah I'm not 100% sure either, but what seems to happen is that (as I wrote in #764 (comment)):
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.
Same thing is allowed in 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.
Uh oh, in both MSL and C it lets you skip fields in the constructor though so
also works?? With no warnings or errors 😟 ??
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.
What's going to happen if the array only has one element? How is the compiler going to figure out if the initializer is for this field or for the
inner
itself? And initializers don't even have to be provided for all the fields. Ugh, C is weird :(