Skip to content

Conversation

@rintaro
Copy link
Member

@rintaro rintaro commented Jul 15, 2025

  • Non primitive types, e.g. arg: MySwiftTy?
    • CDecl: type UnsafeRawPointer? conversion arg?.assumingMemoryBound(to: MySwiftTy.self).pointee
    • Java: type Optional<MySwiftTy>, conversion: arg.map((val) -> val.$memorySegment()).orElse(MemorySegment.NULL)
  • Primitive types, e.g. arg: Int?
    • CDecl: type UnsafePointer<Int>?conversion arg?.pointee
    • Java: type OptionalLong conversion: arg.isPresent() ? arena.allocateFrom(ValueLayout.JAVA_LONG, arg.getAsLong()) : MemorySegment.NULL;
  • Pointer types, e.g. arg: UnsafePointer?
    • Not supported, yet.

@rintaro rintaro force-pushed the jextract-optional-parameter branch from 2094332 to 92cbb5e Compare July 15, 2025 23:08
@rintaro rintaro force-pushed the jextract-optional-parameter branch from 92cbb5e to 2fe946e Compare July 15, 2025 23:27
Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Looks great, thank you 👍

@ktoso ktoso merged commit 19a6785 into swiftlang:main Jul 16, 2025
55 of 56 checks passed
@rintaro rintaro deleted the jextract-optional-parameter branch July 16, 2025 03:41
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