When using the Frege native-gen tool on the JavaFX Animation class it generates Frege code that includes the following:
data Animation = mutable native javafx.animation.Animation where
native getRate :: Animation -> IO Double
native getStatus :: Animation -> IO Animation_Status
but the code does not compile since the Animation_Status type is missing. On the Java side, this is an enum. http://docs.oracle.com/javafx/2/api/javafx/animation/Animation.Status.html
What is the advised way of handling this in the native declaration?
We can generate Frege code for inner classes. The class name that is input to the native-gen tool is the name returned by Class.getName
. For the Animation.Status
enum, it is javafx.animation.Animation$Status
.
$ java -jar native-gen-1.0-SNAPSHOT.jar
Enter class name: javafx.animation.Animation$Status
data Animation_Status = pure native javafx.animation.Animation.Status where
pure native paused "javafx.animation.Animation.Status.PAUSED" :: Animation_Status
pure native running "javafx.animation.Animation.Status.RUNNING" :: Animation_Status
pure native stopped "javafx.animation.Animation.Status.STOPPED" :: Animation_Status
pure native valueOf "javafx.animation.Animation.Status.valueOf" :: String -> Animation_Status
native values "javafx.animation.Animation.Status.values" :: () -> STMutable s (JArray Animation_Status)
derive Serializable Animation_Status
By the way, the native-gen
version I am working on currently can generate Frege code for an entire Java package and its subpackages recursively. We could just give the root package javafx
and it would create Frege modules for all the classes in all its subpackages. I will release this hopefully by the end of this week.