Slackbot
01/30/2020, 8:04 PMkpgalligan
01/31/2020, 2:11 PMprivate val client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer()
}
install(Logging) {
logger = Logger.DEFAULT
level = LogLevel.ALL
}
}
Patrick
01/31/2020, 3:17 PMclass Device {
var didConnectFunc: CFunction<() -> Unit>? = null
fun didConnect() {
didConnectFunc?.ptr?.invoke()
}
}
If I export this as a dynamic C library, I get can set the function to be executed like this:
void *didConnect() {
printf("DID CONNECT\n");
}
lib->kotlin.root.Device.set_didConnectFunc(device, didConnect);
This works fine.
What do I have to do however if I want to pass an Argument to my C function like this:
class Device {
var didConnectFunc: CFunction<(barcode: Barcode) -> Unit>? = null
fun didConnect(barcode: Barcode) {
didConnectFunc?.ptr?.invoke(barcode)
}
}
This code does not compile with the following error message: type [@kotlin.ParameterName] Barcode is not supported here: doesn't correspond to any C type
How would I best solve this problem? Is it possible to create a pointer to the Barcode class and pass that to the function?Sylvain Patenaude
01/31/2020, 4:28 PMswift_name
? And why do I see objc_subclassing_restricted
?
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("SomeHelperKt")))
@interface ProjectNameSomeHelperKt : KotlinBase
GarouDan
02/02/2020, 10:05 PMjava.lang.IllegalStateException: Could not find serialized descriptor for index: -7854123172190848783Does someone know how to solve this problem? I’m using Kotlin
1.3.61
and Gradle 5.5.1
.
I tried to update to latest Kotlin dev 1.3.70-eap-96
but I still have the same problem =/Vincent Chen
02/03/2020, 9:56 AMKavan
02/03/2020, 8:20 PMval str = StringBuilder (); str.append("hello");
var str = ""; str += "hello";
Second is faster then first one.
Shouldn't take same time ? If not then.
When to use first and when to use second ?Kris Wong
02/04/2020, 2:26 PMribesg
02/04/2020, 2:43 PMNativeBuildType
do? When setting it to RELEASE
, it strips the result from at least 2 enums in the code leading to crashesTrond Tunheim
02/05/2020, 10:17 AMNikolay Kasyanov
02/05/2020, 10:54 AMimport kotlin.test.Test
is highlighted red in the IDE when the test is located in the commontTest
source set? Gradle build doesn’t fail, seems like an IDE issue.max.cruz
02/05/2020, 11:10 AMSystem.getProperty("os.name")
to identify the target, so it supposes that it would be needed to use the same OS. Is there some example that you can recommend me about how to set up the project properly for cross-compile?dwursteisen
02/05/2020, 12:04 PMModel
which has a field val transform: Matrix
I want to update this transform matrix but I haven’t found a way to do it.
val model = cValue<Model> { }
// ...
model.useContents {
// create a copy so update are lost
transform.useContents {
m1 = ...
}
}
generated code by cinterop:
public final class Model {
// ...
val transform: Matrix
}
header definition:
• Model: https://github.com/raysan5/raylib/blob/master/src/raylib.h#L365
• Matrix: https://github.com/raysan5/raylib/blob/master/src/raylib.h#L195Brian Stanek
02/05/2020, 1:35 PMClass<SomeProtocol>
that it can internally instantiate when needed.
In kotlin I can create a class that conforms to SomeProtocol
- but I don’t know how to (or if it’s even possible to) get an “Objective-C class” from that class.
I tried passing it as MyClass::class
, but the compiler complains that it got a KClass<MyClass>
but was expecting a SomeProtocol?
- which isn’t quite right, because the API I’m calling expects a class, not an instance.
Using MyClass::class as SomeProtocol
appeases the compiler, but results in a TypeCastException at runtime.
Is there anything analogous to KotlinClass::class.java
in the native world?napperley
02/05/2020, 9:44 PMNikolay Kasyanov
02/06/2020, 10:18 AM@Throws
annotation to one of my Kotlin methods:
!dbg attachment points at wrong subprogram for function
!81136 = distinct !DISubprogram(name: "objc2kotlin.3034", linkageName: "objc2kotlin.3034", scope: !75265, file: !75265, type: !75266, spFlags: DISPFlagDefinition, unit: !1293, retainedNodes: !1295)
i8* (i8*, i8*, i8*, i8**)* @objc2kotlin.3034
%9 = alloca [5 x %struct.ObjHeader*], align 8, !dbg !81156
!81156 = !DILocation(line: 296, column: 9, scope: !81157)
!81157 = distinct !DISubprogram(name: "Kotlin_ObjCExport_getWrappedError", linkageName: "Kotlin_ObjCExport_getWrappedError", scope: !290, file: !290, line: 296, type: !1363, spFlags: DISPFlagDefinition, unit: !289, retainedNodes: !1295)
!81157 = distinct !DISubprogram(name: "Kotlin_ObjCExport_getWrappedError", linkageName: "Kotlin_ObjCExport_getWrappedError", scope: !290, file: !290, line: 296, type: !1363, spFlags: DISPFlagDefinition, unit: !289, retainedNodes: !1295)
warning: ignoring invalid debug info in /var/folders/ch/tb8ry3t16mdgwpjqz8yzw5yc0000gn/T/konan_temp6380746194156800718/MyFramework.kt.bc
warning: no debug symbols in executable (-arch x86_64)
And no debug info seems to be generated for the framework (dSYM file shrinks significantly).
there’s a bunch of warnings preceeding:
warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/username/.konan/kotlin-native-macos-1.3.61/klib/platform/ios_x64/Foundation/targets/ios_x64/native/cstubs.bc with '[2 x i32] [i32 13, i32 2]' from out)
This warnings have been here for quite some time (caused by Xcode 11.3 being the active one on my machine I presume) but haven’t caused any issues so far so I’m not sure if they are related to the issue above or not.Kavan
02/06/2020, 12:39 PMgethostbyname("<http://www.google.com|www.google.com>").pointed.h_addr_list
is array of h_addr but in kotlin it's cpointer of bytearray
How can I get first h_addr element ?
I wanna use it in
nativeHeap.alloc<sockaddr_in>.apply{ sin_addr.s_addr = /* here */ }
fcosta
02/07/2020, 5:02 PMKavan
02/08/2020, 11:33 AMKavan
02/08/2020, 7:29 PMbasher
02/10/2020, 3:51 AMobject
s are initialized during runtime init on native. Does anyone know where that is?Patrick
02/10/2020, 9:47 AMresult
of the call.
(lldb) command script import konan_lldb.py
(lldb) p result
(ObjHeader *) $1776 = {'exception': {'stackTraceStrings$delegate': '...', 'message': 'Bad response: HttpResponse[<https://example.com/v1.0/authentication>, 401 Unauthorized]', 'cause': None, 'stackTrace': ['0x0000000100064397', '0x000000010005d7f5', '0x000000010005d3b5', '0x000000010005d995', '0x00000001002e916f', '0x00000001002e8c00', '0x00000001002ea3ea', '0x00000001002ea980', '0x00000001002f29cd', '0x00000001002f2d04'], 'response': '...'}}
How would I now display the response
property of the result? What is the best way to access it and display it in a readable format?Nikolay Kasyanov
02/11/2020, 8:23 AMbasher
02/11/2020, 9:24 PMlazy
and atomicLazy
? Is lazy
not thread-safe on native?James
02/11/2020, 10:53 PMLuke Kellett
02/12/2020, 7:58 PMkpgalligan
02/13/2020, 1:29 AMNikolay Kasyanov
02/13/2020, 10:02 AMString
and NSString
(in both directions). Seems to be working fine in runtime too. The docs confirm that’s the way to go. Are these false positives?felislynx
02/13/2020, 10:13 AMMyroslav Kolodii
02/13/2020, 11:49 AMpackForXcode
gradle task from Kotlin tutorial (https://play.kotlinlang.org/hands-on/Introduction%20to%20Kotlin%20Multiplatform/01_Introduction). Ideal would be to modify it somehow to get several modules as input and produce one framework on output.