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

Add Support for Static Fields to Java2Swift tool #61

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jrosen081
Copy link
Contributor

Closes #39

This adds support to adding static fields to the Java2Swift tool. The issue recommends adding a @JavaStaticField macro, but it looks like due to the fact that the subscript created by the JavaField macro works for static properties when defined on a JavaClass, so I'm not sure a @JavaStaticField really buys anything here, so I'm open to removing it.

Same testing as in #55 (since that one also adds a static String).

I also noticed that we had a staticMethods array, but were re-requesting all methods in the Java2Swift tool when handling static methods, so I updated it to just use the staticMethods array to simplify the code a bit.

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 good to me but I'll give @DougGregor a chance to answer the question asked 👍

/// ```swift
/// @JavaClass("org.swift.example.HelloSwift")
/// struct HelloSwift {
/// @JavaField
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// @JavaField
/// @JavaStaticField

shouldn't the var be static as well?

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.

JavaKit support for static fields (wrapping Java types in Swift)
2 participants