Implement Kotlin wrapper for C code

Signed-off-by: Billy Brawner <billy@wbrawner.com>
This commit is contained in:
Billy Brawner 2019-11-17 12:55:37 -07:00
parent d8d2b3e612
commit b559d00459
2 changed files with 20 additions and 9 deletions

View file

@ -1,11 +1,12 @@
package com.wbrawner.cverter;
public class ConversionHelper {
static {
System.loadLibrary("c-verter");
}
public static native double celsiusToFahrenheit(double celsius);
public static native double fahrenheitToCelsius(double celsius);
}
// Uncomment to use (but also remember to comment out the Kotlin version
//public class ConversionHelper {
// static {
// System.loadLibrary("c-verter");
// }
//
// public static native double celsiusToFahrenheit(double celsius);
//
// public static native double fahrenheitToCelsius(double celsius);
//}

View file

@ -0,0 +1,10 @@
package com.wbrawner.cverter
object ConversionHelper {
external fun celsiusToFahrenheit(celsius: Double): Double
external fun fahrenheitToCelsius(fahrenheit: Double): Double
init {
System.loadLibrary("c-verter")
}
}