JoakimForslund
08/26/2019, 8:49 AM@CName("Java_com_example_project_createString")
fun createString(env: kotlinx.cinterop.CPointer<JNIEnvVar>, instance: jobject):jstring?{
val jniNativeInterface: JNINativeInterface = env.pointed.pointed!!
val fNewStringUTF = jniNativeInterface.NewStringUTF!!
val result = fNewStringUTF(env, "A test")
return result
}
Where the 'A test' part wont work, because of it not being a jstringsalomonbrys
08/26/2019, 1:32 PMspierce7
08/26/2019, 4:39 PMnapperley
08/27/2019, 2:34 AMTask :cinteropUdevLinux FAILED
Exception in thread "main" java.lang.Error: /tmp/tmp360311134357443805.c:26:3: error: expected expression
JoakimForslund
08/27/2019, 9:14 AMpublic fun AES_CBC_encrypt_buffer(output: kotlinx.cinterop.CValuesRef<platform.posix.uint8_tVar /* = kotlinx.cinterop.UByteVarOf<platform.posix.uint8_t /* = kotlin.UByte */> */>?, input: kotlinx.cinterop.CValuesRef<platform.posix.uint8_tVar /* = kotlinx.cinterop.UByteVarOf<platform.posix.uint8_t /* = kotlin.UByte */> */>?, length: platform.posix.uint32_t /* = kotlin.UInt */, key: kotlinx.cinterop.CValuesRef<platform.posix.uint8_tVar /* = kotlinx.cinterop.UByteVarOf<platform.posix.uint8_t /* = kotlin.UByte */> */>?, iv: kotlinx.cinterop.CValuesRef<platform.posix.uint8_tVar /* = kotlinx.cinterop.UByteVarOf<platform.posix.uint8_t /* = kotlin.UByte */> */>?): kotlin.Unit { /* compiled code */ }
I'm trying to use it with the following setup: https://gist.github.com/Syrou/52db691f91928cb6aad6bcfd84bf5cff
1. Am I wrong in trying to use toCValues() method to translate the uByteArrays into what is specified in the method argument?
2. Am I using the buffer pinning wrong?
Because each time I run this code I end up with a new result. This might
be an error in the c-lib to start with, but I'm currently investigating if my implementation of the native code is wrong.napperley
08/27/2019, 9:30 AMlibusb_get_device_list
function takes a list (parameter) however the list is a container for libusb_device
, which is a opaque pointer. Is there a way to allocate a opaque pointer? Below is the function's mapping:
public fun libusb_get_device_list(ctx: kotlinx.cinterop.CValuesRef<cnames.structs.libusb_context>?, list: kotlinx.cinterop.CValuesRef<kotlinx.cinterop.CPointerVar<kotlinx.cinterop.CPointerVar<cnames.structs.libusb_device> /* = kotlinx.cinterop.CPointerVarOf<kotlinx.cinterop.CPointer<cnames.structs.libusb_device>> */> /* = kotlinx.cinterop.CPointerVarOf<kotlinx.cinterop.CPointer<kotlinx.cinterop.CPointerVarOf<kotlinx.cinterop.CPointer<cnames.structs.libusb_device>>>> */>?): platform.posix.ssize_t /* = kotlin.Long */ { /* compiled code */ }
Jonas Bark
08/28/2019, 3:00 PMcocoapods { ... pod("SignalR-ObjC") }
fails with
> Task :redacted:cinteropSignalR-ObjCIosX64 FAILED
Exception in thread "main" java.lang.Error: /var/folders/5w/vjnd8mf17jlclpg31lfzlk0h0000gn/T/tmp3333782877975402348.m:1:9: fatal error: module 'SignalR' not found
napperley
08/29/2019, 3:50 AMtateisu
08/29/2019, 4:06 AMGlen
08/30/2019, 10:42 PMArkadii Ivanov
08/31/2019, 2:11 AMlinkDebugTestLinuxX64
failing with error message e: Unable to compile C bridges
on Ubuntu: you have to install libtinfo5
and perhaps libtinfo-dev
packages. Wasted 1h on this problem 😞napperley
08/31/2019, 8:46 AMCArrayPointer<UByteVar>
to a String?Akram
08/31/2019, 7:21 PMmolikuner
08/31/2019, 10:12 PMlinkDebugExecutableWasm32
. Kotlin 1.3.41 is working fine.Tobi
09/02/2019, 6:29 AMVincent Chen
09/02/2019, 3:17 PMribesg
09/03/2019, 10:07 AM> Task :...:bugsnag:cinteropBugsnagIos
Exception in thread "main" java.lang.IllegalStateException: clang_parseTranslationUnit2 failed with CXError_ASTReadError;
sourceFile = /var/folders/6l/fxc2038542q1pfrjs6br35pw0000gn/T/tmp447253035168640890tmp5260654680929876680.m
arguments = -framework Bugsnag -fmodules -isystem /Users/me/.konan/dependencies/clang-llvm-6.0.1-darwin-macos/lib/clang/6.0.1/include -B/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -fno-stack-protector -stdlib=libc++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.4.sdk -miphoneos-version-min=9.0.0 -I/Users/me/IdeaProjects/.../bugsnag/Carthage/Build/iOS/Bugsnag.framework/Headers -fobjc-arc -include-pch /var/folders/6l/fxc2038542q1pfrjs6br35pw0000gn/T/tmp1938929871985065456.pch -Werror=implicit-function-declaration -ferror-limit=0
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.parseTranslationUnit(Utils.kt:99)
at org.jetbrains.kotlin.native.interop.indexer.MacroConstantsKt.expandMacros(MacroConstants.kt:66)
at org.jetbrains.kotlin.native.interop.indexer.MacroConstantsKt.findMacros(MacroConstants.kt:34)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:999)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:952)
at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:91)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:222)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:38)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:69)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:18)
Cyrille QUÉMIN
09/03/2019, 12:33 PMDenis Shurygin
09/03/2019, 12:50 PMNSBundle.localizedStringForKey
doesn't work properly in pair with NSString.localizedStringWithFormat
. Looks like NSString
losing some metadata during conversion into Kotlin String
.
Here is example on Kotlin:
import platform.Foundation.NSBundle
import platform.Foundation.NSString
import platform.Foundation.localizedStringWithFormat
class TestClass(private val bundle: NSBundle) {
fun localizedStringWithFormat(string: String): String {
return NSString.localizedStringWithFormat(
this.bundle.localizedStringForKey(string, "", "Localizable"), 5)
}
}
Here is the code in swift:
let testClass = TestClass(bundle: Bundle.main)
let testString = "screen_main_plural_string"
let nativeStr = Bundle.main.localizedString(forKey: testString, value: "", table: "Localizable") as NSString
NSLog("swift: %@", NSString.localizedStringWithFormat(nativeStr, 5))
NSLog("kotlin: %@", testClass.localizedStringWithFormat(string: testString))
Output logs:
swift: Plural: 5 apples
kotlin: %#@value@Arkadii Ivanov
09/03/2019, 11:29 PMCyrille QUÉMIN
09/04/2019, 9:55 AMw: Interop library /pathToUser/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-io-iosarm64/0.1.14/1ece4fc59ccddcacf23bb04589c7c0f39a94b787/kotlinx-io-cinterop-sockets can't be exported with -Xexport-library
. Will I experience runtime crashes ? what does it mean exactly for the framework produced ?galex
09/04/2019, 1:00 PMgalex
09/04/2019, 1:15 PMserebit
09/04/2019, 2:42 PMVincent Chen
09/04/2019, 5:53 PM.....
var outputLength = cValuesOf(0)
......
val outputBA = outputData.readBytes(outputLength convert int)
How to Convert outputLength to Int
Thanksnapperley
09/04/2019, 9:21 PMVincent Chen
09/05/2019, 3:57 AMJustin
09/05/2019, 8:17 PMVincent Chen
09/06/2019, 8:21 AMSam Schilling
09/06/2019, 4:38 PMfun elapsedRealtime() = (NSProcessInfo().systemUptime * 1_000)
val startTime = elapsedRealtime()
var currentTime = startTime
while (currentTime - startTime < 150) {
currentTime = elapsedRealTime()
}
I would think NSProcessInfo objects should automatically be deallocated each time elapsedRealtime
completes since the reference count would be 0, but I am unsure how Kotlin’s GC interacts with Swift/Objective-C’s ARC
If I change the loop to run for 25 seconds for example my memory usage shoots up nearly 500 MB.
This is running on macOS 10.14.6