Jeff Lockhart
07/21/2022, 1:03 AMUndefined symbols for architecture x86_64:
"_OBJC_CLASS_$_CBLC4Document", referenced from:
objc-class-ref in result.o
"_c4db_getDoc", referenced from:
_cocoapods_CouchbaseLite_c4db_getDoc_wrapper0 in result.o
ld: symbol(s) not found for architecture x86_64
The function c4db_getDoc()
is implemented in the library here. Its declaration just isn't in the framework's public headers, which is why I added it as a custom definition. Its internal declaration is in this .h file. I've declared it this same way in the .def (along with the struct parameter types):
C4Document* c4doc_get(C4Database *database, C4String docID, bool mustExist, C4Error* outError);
Would the issue be that the implementation is in a .cc C++ file and Kotlin doesn't support C++ interop? If so, is there some way I could access this function?napperley
07/21/2022, 2:16 AMfun runFunction(argPtr: COpaquePointer?): Int = memScoped {
val tmpCmd = argPtr?.asStableRef<Command>()?.get() ?: throw IllegalStateException("Command cannot be null")
val argv =
if (tmpCmd.args.isEmpty()) arrayOf(tmpCmd.filePath, "").toCStringArray(this)
else arrayOf(tmpCmd.filePath, *tmpCmd.args.toTypedArray()).toCStringArray(this)
val status = alloc<IntVar>()
val fileDescriptors = allocArray<IntVar>(2)
createPipe(fileDescriptors)
val pid = fork()
if (pid == 0) {
close(fileDescriptors[READ_POS])
dup2(fileDescriptors[WRITE_POS], STDOUT_FILENO)
dup2(fileDescriptors[WRITE_POS], STDERR_FILENO)
execvp(tmpCmd.filePath, argv)
}
close(fileDescriptors[WRITE_POS])
val file = openFileDescriptor(fileDescriptors[READ_POS])
tmpCmd.output += file.readLines(10u)
file.close()
wait_for_process(status.ptr)
status.value
}
In the callback the command output is stored in tmpCmd as a StableRef ( https://kotlinlang.org/api/latest/jvm/stdlib/kotlinx.cinterop/-stable-ref/ ). Why isn't the changed state of the StableRef accessible outside of the callback?napperley
07/21/2022, 3:26 AMribesg
07/21/2022, 7:47 AMJoey
07/21/2022, 12:18 PMJeff Lockhart
07/21/2022, 7:37 PMinitWith...
functions (constructors) in an ObjC category in a .def file? I've had success declaring properties and functions that aren't in the public API of an ObjC class, but adding an initWith...
function doesn't add the constructor definition (or the @Deprecated initWith...
function that is usually generated with the constructor).
For example, where MyObjCClass
is previously declared in a public API header:
@interface MyObjCClass (Internal)
@property (nonatomic, readonly, nonnull) NSString *foo;
- (BOOL) isBar;
- (instancetype) initWithFoo: (NSString)foo bar: (BOOL)bar;
@end
Adds extension functions on the class definition, instead of modifying the class defined by the public API header:
expect val MyObjCClass.foo: NSInteger
@ObjCCallable external expect fun MyObjCClass.foo(): NSInteger
@ObjCCallable external expect fun MyObjCClass.isBar(): Boolean
There is nothing added for the initWithFoo:bar:
constructor though.ankushg
07/21/2022, 8:51 PMsealed interface MyCollectionClass {
val collection: Collection<String>
}
data class MyListClass: MyCollectionClass {
override val collection: List<String>
}
data class MySetClass: MyCollectionClass {
override val collection: Set<String>
}
Within Kotlin, when we that our concrete type is a MyListClass
, we also know that collection
is of type List<String>
But in Swift, even when we know we have an instance of MyListClass
, the type of collection
looks like a Collection<String>
I think this is only the case with `sealed interface`s — `sealed class`es seem to be working as expected.Tlaster
07/22/2022, 5:34 AMmacos()
instead of macosX64() macosArm64()
like ios()
in kotlin target config?Trey
07/22/2022, 2:11 PMp4czyk
07/23/2022, 4:15 PMp4czyk
07/23/2022, 5:41 PMJeff Lockhart
07/25/2022, 5:19 AMByteArray
and not `unpin()`ing it? Would this only prevent GC from relocating the memory, or would it cause a memory leak?
My issue is with returning a native pointer to an internal ByteArray
buffer as a stable reference, where the caller uses the pointer, but can't call unpin()
after doing so.Landry Norris
07/25/2022, 7:24 PMbod
07/25/2022, 9:45 PMfun main() {
runBlocking {
withContext(Dispatchers.Main) {
println("Hello, World!")
}
}
}
With the new memory manager enabled, the message is never printed, the thread seems to be stuck on withContext
.
I’m not sure if this is to be expected - something like runBlocking
blocking the main thread and making dispatching ineffective? … But then again it feels like this should work, and also looks like a regression since it works with the old MM? 🤔
Any insight would be appreciated! 🙏
Repro project here.Edoardo Luppi
07/26/2022, 9:27 AMplatform.windows.LPWSTR? /* = kotlinx.cinterop.CPointer<platform.windows.WCHARVar /* = kotlinx.cinterop.UShortVarOf<kotlin.UShort> */>
for creating a https://docs.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_table_entrya struct.
I'm stuck on the lpServiceName
member, no idea how to obtain a value for it.
Edit: maybe I got it.
lpServiceName = "MyString".wcstr.ptr
Edoardo Luppi
07/26/2022, 9:55 AMMatthew Murray
07/26/2022, 7:45 PMMiroslav Sobotka
07/27/2022, 11:05 PMLandry Norris
07/29/2022, 3:46 PMLeon Kiefer
07/29/2022, 5:12 PMAutofreeScope
and Arena
work? do they automatically free the allocated memory when they are garbage collected, or is there some other mean to ensure native memory is freed if a kotlin object is garbage collected? We are currently wrapping a native library with a common code api and can not expose native memory management in the common code api.fwsGonzo
07/31/2022, 6:50 AMstatic_kref_kotlin_Array args;
args.pinned = NULL;
syms->kotlin.root.main(args);
This works fine, but then predictably the program arguments are null
Does anyone know how to pass the program arguments to Kotlin?jmfayard
07/31/2022, 5:14 PMLandry Norris
08/01/2022, 5:01 PMzt
08/02/2022, 1:04 AMval windowAttributes dpy.getWindowAttributes(window)
val windowAttributes = nativeHeap.alloc<XWindowAttributes>() {
XGetWindowAttributes(display.ptr, window, ptr)
}
// Do some stuff
nativeHeap.free(windowAttributes)
zt
08/02/2022, 8:10 PMstrip
command on it shrinks it to 3.1 mb.Jozef Matus
08/03/2022, 10:04 AMkonan_lldb.py
which helps interpretting non-basic structure and tells you little bit more then just ObjHeader *
. But still, output of v
command in lldb is this
(ObjHeader *) context = [keysArray: ..., valuesArray: ..., presenceArray: ..., hashArray: ..., keysView: ..., valuesView: ..., entriesView: ..., maxProbeDistance: ..., length: ..., hashShift: ..., _size: ..., isReadOnly: ...]
I would like to be able to print keys/values and I cant find the way to do that. Do anybody know how to do that?
Thank you a lot 🙂Tim Ortel
08/03/2022, 1:59 PMpod("gRPC-ProtoRPC", version = "~> 1.48", moduleName = "ProtoRPC")
However, my Gradle Task fails with fatal error: module 'ProtoRPC' not found
I have tried the steps suggested in https://kotlinlang.org/docs/native-cocoapods.html#possible-issues-and-solutions. However, there was no module.modulemap in build/cocoapods/synthetic/Pods/gRPC-ProtoRPC. I found one in build/cocoapods/synthetic/Pods/Target Support Files/gRPC-ProtoRPC but that one says: framework module ProtoRPC.
What is the easiest way of getting access to the Objective-C implementation of GRPC in Kotlin Multiplatform?Trey
08/03/2022, 7:34 PMmbonnin
08/04/2022, 12:47 PMIncompatible abi version
)
1. is that true?
2. could we allow consumption with 1.6 by adding languageVersion = "1.6"
when compiling? Looks like this works for JVM but not for native?Tim Ortel
08/04/2022, 2:48 PM#if !__has_feature(objc_fixed_enum)
#error All supported Xcode versions should support objc_fixed_enum.
#endif
Can I enable this support in my .def file? Sorry if this is not the right place to ask this question.Tim Ortel
08/04/2022, 2:48 PM#if !__has_feature(objc_fixed_enum)
#error All supported Xcode versions should support objc_fixed_enum.
#endif
Can I enable this support in my .def file? Sorry if this is not the right place to ask this question.Landry Norris
08/04/2022, 3:03 PMTim Ortel
08/04/2022, 3:04 PMLandry Norris
08/04/2022, 3:07 PM