-
Notifications
You must be signed in to change notification settings - Fork 67
jextract (ffm, jni): Subscripts support #459
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
2977c8a
61995aa
55c5fd4
a3ae108
9528fb3
8085fb1
9711e4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,4 +61,9 @@ public struct MySwiftStruct { | |
| public func makeRandomIntMethod() -> Int { | ||
| return Int.random(in: 1..<256) | ||
| } | ||
|
|
||
| public subscript() -> Int { | ||
| get { return len } | ||
| set { len = newValue } | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about a case with parameters?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't notice I lost them in git stash :/ Fixed |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,4 +33,15 @@ void create_struct() { | |
| assertEquals(len, struct.getLength()); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void testSubscript() { | ||
| try (var arena = AllocatingSwiftArena.ofConfined()) { | ||
| MySwiftStruct s = MySwiftStruct.init(1337, 42, arena); | ||
| long currentValue = s.getSubscript(); | ||
| s.setSubscript(66); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
| assertEquals(42, currentValue); | ||
| assertEquals(66, s.getLength()); | ||
| } | ||
| } | ||
| } | ||
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.
can it set some other value and not the
lenperhaps? Just so we don't step on values when we write bigger tests