Konstantin Petrukhnov
11/04/2019, 9:24 AMEamonn Boyle
11/04/2019, 11:09 PMVsevolod Ganin
11/05/2019, 3:53 PMNSException
from K/N (via NSException.raise
) and catch it in ObjC. Unfortunately it is not catched and program still crashes. If I raise it in the same spot but in ObjC it is catched just fine. Is it a known problem? Hasn’t been able to find any info on the subject except for the one line in docs (https://kotlinlang.org/docs/reference/native/objc_interop.html#errors-and-exceptions):
Swift/Objective-C error-throwing methods aren’t imported to Kotlin as exception-throwing.
Andy Gibel
11/05/2019, 9:36 PMThomas
11/06/2019, 4:22 PMval identityBytes: ByteArray = someValue()
val pskBytes: ByteArray = someValue()
// <https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_set_psk_client_callback.html>
SSL_CTX_set_psk_client_callback(ctx, staticCFunction { ssl, hint, identity, maxIdentityLen, psk, maxPskLen ->
require(identityBytes.size <= maxIdentityLen.toInt())
require(pskBytes.size <= maxPskLen.toInt())
identityBytes.forEachIndexed { index, value ->
identity!![index] = value
}
pskBytes.forEachIndexed { index, value ->
psk!![index] = value.toUByte()
}
// ...
TODO()
})
When compiling this gives an error:
kotlinx.cinterop.staticCFunction must take an unbound, non-capturing function or lambda
I need to access identityBytes and pskBytes from this lambda. Is that possible?Kris Wong
11/06/2019, 4:49 PMAndy Gibel
11/06/2019, 6:55 PMEamonn Boyle
11/06/2019, 10:23 PMPatrick
11/07/2019, 9:08 AMKris Wong
11/07/2019, 4:23 PMmmap
as a CPointer<ByteVar>
would cause a SIGBUS?Patrick
11/07/2019, 4:39 PMArkadii Ivanov
11/07/2019, 8:17 PMUncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared kotlin.collections.ArrayList@3edc938 from other thread
at 0 MppLib 0x000000010ce1c165 kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception + 85
at 1 MppLib 0x000000010ce1b4c5 kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException + 85
at 2 MppLib 0x000000010ce460d5 kfun:kotlin.native.IncorrectDereferenceException.<init>(kotlin.String)kotlin.native.IncorrectDereferenceException + 85
at 3 MppLib 0x000000010ce48058 ThrowIllegalObjectSharingException + 744
at 4 MppLib 0x000000010cff3d79 _ZNK16KRefSharedHolder14verifyRefOwnerEv + 185
at 5 MppLib 0x000000010d000efc -[KMutableListAsNSMutableArray dealloc] + 44
at 6 libobjc.A.dylib 0x00007fff50bad0d6 _ZN11objc_object17sidetable_releaseEb + 174
at 7 libobjc.A.dylib 0x00007fff50bae75b _ZN19AutoreleasePoolPage12releaseUntilEPP11objc_object + 147
at 8 libobjc.A.dylib 0x00007fff50bae67a objc_autoreleasePoolPop + 199
at 9 libobjc.A.dylib 0x00007fff50bae9c4 _ZN19AutoreleasePoolPage11tls_deallocEPv + 112
at 10 libsystem_pthread.dylib 0x00007fff51bfe6ab _pthread_tsd_cleanup + 551
at 11 libsystem_pthread.dylib 0x00007fff51c01655 _pthread_exit + 70
at 12 libsystem_pthread.dylib 0x00007fff51bfe2f6 _pthread_body + 137
at 13 libsystem_pthread.dylib 0x00007fff51c01249 _pthread_start + 66
at 14 libsystem_pthread.dylib 0x00007fff51bfd40d thread_start + 13
(lldb)
Frank Feng
11/08/2019, 12:34 PMKris Wong
11/08/2019, 3:44 PMval stat = cValue<stat>()
, and I want to pass it to the stat
funciton , which takes a stat*
, do I need to use getPointer
? the posix binding accepts a CValuesRef
. i just want to pass a pointer to the stack variable.thymecypher
11/08/2019, 10:26 PMTim Hauptmann
11/11/2019, 9:43 AMprivate var readStream: Unmanaged<CFReadStream>?
private var writeStream: Unmanaged<CFWriteStream>?
private var inputStream: InputStream?
private var outputStream: OutputStream?
func connect(
hostname: String,
port: Int32,
callback: @escaping (_ dataTransferObject: DiagnoseViewDataTransferObject) -> Void
) {
let host = CFStringCreateWithCString(kCFAllocatorDefault, hostname, CFStringBuiltInEncodings.UTF8.rawValue)
CFStreamCreatePairWithSocketToHost(
kCFAllocatorDefault,
host,
443,
&self.readStream,
&self.writeStream
)
inputStream = readStream?.takeRetainedValue()
outputStream = writeStream?.takeRetainedValue()
inputStream!.delegate = self
outputStream!.delegate = self
}
----------------
In Kotlin I have the following:
private var readStream: CValuesRef<CFReadStreamRefVar>? = null
private var writeStream: CValuesRef<CFWriteStreamRefVar>? = null
private var inputStream: NSInputStream? = null
private var outputStream: NSOutputStream? = null
fun connect(
hostname: String,
port: Int,
callback: (dataTransferObject: DiagnoseViewDataTransferObject) -> Unit
) {
val host = CFStringCreateWithCString(kCFAllocatorDefault, hostname, kCFStringEncodingUTF8)
CFStreamCreatePairWithSocketToHost(
alloc = kCFAllocatorDefault,
host = host,
port = 443,
readStream = this.readStream,
writeStream = this.writeStream
)
inputStream = readStream as NSInputStream?
outputStream = writeStream as NSOutputStream?
inputStream!!.delegate = this //crashes here with Nullpointer
outputStream!!.delegate = this
}
Someone can help me how to use CFStreamCreatePairWithSocketToHost from Kotlin?alex009
11/13/2019, 2:22 AMReceiver of 'initBy' must be a 'this' of the constructed class
? class is simple:
@ExportObjCClass
class MyTableViewCell : UITableViewCell {
@OverrideInit
constructor(
style: UITableViewCellStyle,
reuseIdentifier: String?
) : super(style = style, reuseIdentifier = reuseIdentifier)
@OverrideInit
constructor(coder: NSCoder) : super(coder = coder)
}
Andy Gibel
11/13/2019, 3:11 PMS Korebrits
11/13/2019, 4:05 PMexpect fun <T> runTest(block: suspend () -> T)
JVM
actual fun <T> runTest(block: suspend () -> T) {
runBlocking { block() }
}
https://blog.kotlin-academy.com/testing-common-modules-66b39d641617
https://youtrack.jetbrains.com/issue/KT-22228
How would I implement this vor the Native side? Or is there an better solution to this problem.Adam Lusch
11/13/2019, 5:49 PMinterface Interface {
fun foo(): Int
}
class Concrete : Interface {
override fun foo() = 42
fun bar() = 1337
}
fun getInterface(): Interface = Concrete()
is it legal to check IsInstance
and "cast" by using the pinned interface pointer as the concrete type?
KotlinInterfaceTest_ExportedSymbols* lib = KotlinInterfaceTest_symbols();
auto sample = lib->kotlin.root.sample;
KotlinInterfaceTest_kref_sample_Interface interface = sample.getInterface();
if (lib->IsInstance(interface.pinned, sample.Concrete._type()))
{
auto concrete = KotlinInterfaceTest_kref_sample_Concrete{ interface.pinned };
printf("Call concrete method: %d\n", sample.Concrete.bar(concrete));
}
This seems to work (prints "Call concrete method: 1337"), but want to make sure I'm not relying on undefined behavior. Thanks!Andy Gibel
11/13/2019, 7:08 PMolonho
11/14/2019, 5:06 AMVector128
along with interop support, so frameworks like ModelIO
and SpriteKit
now expose APIs with SIMD types like vector_float3
.Slackbot
11/14/2019, 8:19 PMSamuel Michael
11/14/2019, 9:00 PMAndy Gibel
11/15/2019, 4:19 PMYoshiRulz
11/15/2019, 5:02 PMKris Wong
11/15/2019, 7:57 PMos_log
function appears to be missing from the iOS platform bindingsserebit
11/16/2019, 4:06 PMUnable to compile C bridges
with Kotlin/Native 1.3.60. Referring to https://github.com/JetBrains/kotlin-native/issues/2674, shouldn't this have been fixed with the LLVM toolchain update?Robert
11/17/2019, 8:42 AMPatrick
11/18/2019, 2:15 PMPatrick
11/18/2019, 2:15 PMArtyom Degtyarev [JB]
11/18/2019, 2:42 PMPatrick
11/18/2019, 4:09 PMArtyom Degtyarev [JB]
11/19/2019, 8:21 AMPatrick
11/19/2019, 8:22 AMArtyom Degtyarev [JB]
11/19/2019, 8:48 AMtestTaskDelay()
, I will be able to say something more concrete.Patrick
11/19/2019, 11:45 AMArtyom Degtyarev [JB]
11/19/2019, 12:19 PMPatrick
11/19/2019, 12:25 PMArtyom Degtyarev [JB]
11/20/2019, 12:27 PM