Skip to content

[JExtract] Translate String to a imported type #337

@rintaro

Description

@rintaro

Swift.String should be translated to an imported String type instead of java.lang.String, just like Foundation.Data.

In JExtract/FFM, String is currently translated to java.lang.String and lowered to C-string (UnsafePointer<Int8>).
That works for parameters, but is making passing String value between Swift and Java more expensive than it should be. Also it does not work well for API returning String because the client has to manually free the memory.

For example, using this interface,

public func getSomeString() -> String
public func receiveString(str: String)

In Java:

var str = MyLib.getSomeString()
receiveString(str)

This receiving and passing string value should not cause copy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:jextractIssues related to jextract-swift

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions