Sander Saelmans
06/24/2020, 8:31 AM/**
* Some documentation
*
* blablabla
*/
object SomeObject : SomeObjectFacade() {
...
}
Ragyal
06/25/2020, 8:08 PMCraftSpider
06/26/2020, 3:22 AMnapperley
06/26/2020, 7:06 AMamqp_basic_publish
function is returning 0 (this means the message has been successfully transmitted to the Broker). Below is the code that is being used to publish the message:
private fun publishMessage(conn: amqp_connection_state_t?) = memScoped {
val props = alloc<amqp_basic_properties_t>()
with(props) {
_flags = (AMQP_BASIC_CONTENT_TYPE_FLAG or AMQP_BASIC_DELIVERY_MODE_FLAG).toUInt()
// TODO: Figure out how to set the AMQP content type.
// content_type = amqp_cstring_bytes("text/plain")
// Persistent delivery mode.
delivery_mode = 2.toUByte()
}
println("Publishing message...")
val publishRc = amqp_basic_publish(
state = conn,
channel = channel,
exchange = amqp_cstring_bytes(EXCHANGE),
routing_key = amqp_cstring_bytes(ROUTING_KEY),
mandatory = 0,
immediate = 0,
properties = props.ptr,
body = amqp_cstring_bytes(MSG_BODY)
)
if (publishRc != 0) println("Cannot publish message.")
Unit
}
Paul Woitaschek
06/26/2020, 12:25 PMnapperley
06/27/2020, 12:09 AMUgi
06/27/2020, 10:31 AM.convert()
on primitive integer/long, but in this case also applied to arrays.
To be clear, something similar to this:
val uIntOrULongArray = arrayof(15L.convert())
Mananpoddarm
06/28/2020, 4:57 AMLuoqiaoyou
06/29/2020, 8:01 AMaleksey.tomin
07/03/2020, 8:02 AMpackage = wlanapi
headers = wlanapi.h
headerFilter = wlanapi.h
2. Add to gradle build file
mingwX64("mingw") {
compilations["main"].cinterops.create("wlanapi")
}
On gradlew I have error:
> Task :sdk:cinteropWlanapiMingw
Exception in thread "main" java.lang.Error: C:\Users\alxt\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1\x86_64-w64-mingw32\include\ntddndis.h:99:11: error: unknown type name 'ULONG
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1003)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:992)
at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:91)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:230)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:46)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:44)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:37)
gradlew --version
------------------------------------------------------------
Gradle 6.5.1
------------------------------------------------------------
Build time: 2020-06-30 06:32:47 UTC
Revision: 66bc713f7169626a7f0134bf452abde51550ea0a
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 11.0.7 (<http://Amazon.com|Amazon.com> Inc. 11.0.7+10-LTS)
OS: Windows 10 10.0 amd64
kotlin: 1*.3.72*
What can I do to fix it?willyrs
07/03/2020, 5:57 PMval splashReducer: Reducer<SplashState> = { state, action -> return state }
and when I call it I have a EXC_BAD_ACCESS (code=1, address=0x0) error
If I write the function like this:
fun splashReducer(state: SplashState, action: Any) : SplashState { return state }
it works!
Do you think it’s a problem with reduxkotlin or with kotlin-native?
P.S. On kotlin-android it works with bothtylerwilson
07/03/2020, 8:10 PM/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/cpp/ObjCExport.mm:345: runtime assert: Unable to add 'toKotlin:' method to NSBlock class
I get this when accessing Kotlin/Native code from Objective-C and having a Swift Framework wrapper also present. Calling from Swift there is no issue.Piasy
07/04/2020, 9:34 AMIaroslav Postovalov
07/05/2020, 4:53 PMnapperley
07/05/2020, 11:10 PMnapperley
07/06/2020, 3:31 AMPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1682 telemet+ 20 0 113.0m 11.2m 3.3m S 0.0 0.3 63:40.01 node_expor+
5342 telemet+ 20 0 111.9m 11.3m 9.0m S 0.0 0.3 0:04.35 sunny_isla+
By contrast node_exporter (a program written in Go - https://github.com/prometheus/node_exporter ) is using a similar amount of memory (around 11.2 MB). Unfortunately the Ktor Client library (the Kotlin Native version) can't be used by sunny_island_telemetry since it has the nasty habit of leaking memory badly, therefore the libcurl library is used to keep memory usage under control.aleksey.tomin
07/06/2020, 10:30 AMprivate fun ensureSuccess(result: UInt) {
require(result.toInt() == ERROR_SUCCESS) { "WinApi error: $result"}
}
...
memScoped {
val phClientHandle = alloc<HANDLEVar>()
val version = alloc<DWORDVar>()
ensureSuccess(WlanOpenHandle(2, null, version.ptr, phClientHandle.ptr))
val ifsList = nativeHeap.allocArray<PWLAN_INTERFACE_INFO_LISTVar>(10)
ensureSuccess(WlanEnumInterfaces(phClientHandle.ptr, null, ifsList))
}
The second call returns 6 ERROR_INVALID_HANDLE
What am I doing wrong?Iaroslav Postovalov
07/07/2020, 8:42 AMva_list
?aleksey.tomin
07/07/2020, 12:51 PMorg.jetbrains.kotlinx:kotlinx-serialization
?
2. I’ve found example for OSX but can’t understand how convert it to kotlin: https://stackoverflow.com/questions/21791702/nsxmlparser-simple-example
3. And how can I override this methods:
@kotlinx.cinterop.ExternalObjCClass public interface NSXMLParserDelegateProtocol : platform.darwin.NSObjectProtocol {
@kotlinx.cinterop.ObjCMethod public open fun parser(parser: platform.Foundation.NSXMLParser, didEndMappingPrefix: kotlin.String): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open fun parser(parser: platform.Foundation.NSXMLParser, foundCharacters: kotlin.String): kotlin.Unit { /* compiled code */ }
...
aleksey.tomin
07/08/2020, 6:18 AMPWLAN_INTERFACE_INFO_LIST pIfList = NULL;
WlanEnumInterfaces(hClient, NULL, &pIfList);
for (i = 0; i < (int) pIfList->dwNumberOfItems; i++) {
PWLAN_INTERFACE_INFO pIfInfo = (WLAN_INTERFACE_INFO *) &pIfList->InterfaceInfo[i];
How can I convert this code to kotlin?
memScoped {
val zeroValue: CValue<PWLAN_INTERFACE_INFO_LISTVar> = zeroValue()
val ppInterfaceList: CPointer<CPointerVarOf<CPointer<_WLAN_INTERFACE_INFO_LIST>>> = zeroValue.getPointer(memScope)
WlanEnumInterfaces(wlanHandle, null, ppInterfaceList)
val pInterfaceList: CPointerVarOf<PWLAN_INTERFACE_INFO_LIST> = ppInterfaceList.pointed
val interfaceList: PWLAN_INTERFACE_INFO_LIST? = pInterfaceList.value
val wlanIfsInfoList: _WLAN_INTERFACE_INFO_LIST? = interfaceList?.pointed
for (pIfInfo ????????)
}
Jamie Craane
07/08/2020, 2:21 PMPiasy
07/12/2020, 12:12 PMfreezeSubgraph
function of Memory.cpp
:
#if USE_GC
// Now remove frozen objects from the toFree list.
// TODO: optimize it by keeping ignored (i.e. freshly frozen) objects in the set,
// and use it when analyzing toFree during collection.
auto state = memoryState;
for (auto& container : *(state->toFree)) {
if (!isMarkedAsRemoved(container) && container->frozen()) {
RuntimeAssert(newlyFrozen.count(container) != 0, "Must be newly frozen"); // <=== here
container = markAsRemoved(container);
}
}
#endif
The abort seems happen randomly, I really don't know what's wrong with my code.
I tried to comment this line, it seems work fine, I'd like to know what's the possible problem if this condition is false? Would there be other problem if I comment this code?
Thank you! I really need your help, genius at JB!napperley
07/13/2020, 4:35 AMaleksey.tomin
07/14/2020, 9:26 AMval pSensorManager = zeroValue<ISensorManager>().getPointer(memScope)
CoCreateInstance(CLSID_SensorManager.ptr, null, CLSCTX_INPROC_SERVER.toUInt(), IID_ISensorManager.ptr, pSensorManager.reinterpret())
pSensorManager.pointed.lpVtbl?.pointed?.let { sensorManagerVtbl: ISensorManagerVtbl ->
println("----AddRef: ${sensorManagerVtbl.AddRef?.rawValue}") // looks like a ref: 0x7ffebe937468
println("----GetSensorsByCategory: ${sensorManagerVtbl.GetSensorsByCategory?.rawValue}") // looks like a ref: 0x-45520ff300000000
println("----GetSensorsByType: ${sensorManagerVtbl.GetSensorsByType?.rawValue}") // look like error: 0x-1
sensorManagerVtbl.AddRef?.invoke(pSensorManager) // Error: User-mode data execution prevention (DEP) violation at location 0x7ffebe937468
sensorManagerVtbl.GetSensorsByCategory?.invoke(pSensorManager, SENSOR_CATEGORY_LOCATION.ptr, pSensorCollection) // The same error
What do I wrong?Madhava
07/15/2020, 12:26 AMzsperske
07/16/2020, 12:48 AMcinterop
for an iOS target. Besides the kotlin official docs, does anyone know of a good github example or blog post that details how to go about pulling a .framework
into your iOSMain
kotlin code?aleksey.tomin
07/17/2020, 6:06 AMval portShort = 8888.toUShort()
val loopbackAddr = alloc<sockaddr_in>()
loopbackAddr.sin_addr.s_addr = INADDR_LOOPBACK
loopbackAddr.sin_family = AF_INET.convert()
loopbackAddr.sin_port = portShort
...
val daemon = MHD_start_daemon(
MHD_USE_POLL_INTERNALLY,
portShort,
null,
null,
staticCFunction(::processRequest), cPointer,
MHD_OPTION_SOCK_ADDR, loopbackAddr.ptr,
MHD_OPTION_END
)
If I remove MHD_OPTION_SOCK_ADDR, loopbackAddr.ptr
- it works.
But with this option daemon is null.
What do I wrong?phldavies
07/17/2020, 12:30 PMmsg: CPointer<ByteVar>?, args: va_list?
? I’m attempt to pass staticCFunction { _: COpaquePointer?, msg: CPointer<ByteVar>?, args: va_list? -> }
to an API but I’m not sure how to make use of the parameters.ursus
07/18/2020, 5:18 AMPaul Woitaschek
07/18/2020, 8:25 AM