I figured I could do something like that, but even...
# kotlin-native
w
I figured I could do something like that, but even if I made my own c wrappers, I can't figure out any way to get a reference to a kotlin object into the callback without just making a global variable and storing it temporarily. Kind've sucks, but that may be the only workaround. I can just make a soft constraint that only one call may be made at a time. This all has to occur on the ui thread anyway, so it's not like I need to worry about concurrent access.
the other cleaner, but slower solution is to put like a hash map to continuations as a global variable, key it with a pointer as a long to the param1 passed in, and then within the callback, just get the pointer as long again and fetch out of the hashmap. Obviously a very poor performance solution, but it works 😕
reread the documentation stem to stern and learned that StableRef is specifically for this purpose and it worked like a charm. I added a void * to the param1 struct, grabbed the stable ref from the continuation and stored it on the struct, and then restored the object from the stable ref within the callback and was able to resume the coroutine without issue.