Zh Efimenko
06/20/2019, 10:29 AMPstFile (*PstFile)(const char* filePath, const char* mode);
When I call this constructor in C code I pass 2 string: PstFile.PstFile("/home/evgeni/Projects/SAGO/NLC/source.pst", "rb");
But in my library I get another string: @&�9�
and rb
if I swap the parameters, I get another string: @���~
and /home/evgeni/Projects/SAGO/NLC/source.pst
. Why first parameter anyhow?Artyom Degtyarev [JB]
06/20/2019, 12:55 PMZh Efimenko
06/20/2019, 1:11 PMclass PstFile(
filePath: String, //(failed string)
mode: String //(normal string)
) : Closeable {
init {
println(filePath)
println(mode)
}
...
override fun close() {}
}
C code:
typedef libpst_kref_com_tullynore_pst_PstFile PstFile;
int main() {
libpst_ExportedSymbols *lib = libpst_symbols();
const char *filePath = "/home/evgeni/Projects/SAGO/NLC/source.pst";
const char *mode = "rb";
PstFile pstFile = lib->kotlin.root.com.tullynore.pst.PstFile.PstFile(filePath,mode);
const char *storeName = lib->kotlin.root.com.tullynore.pst.PstFile.getMessageStoreName(pstFile);
printf("%s\n", storeName);
lib->DisposeStablePointer(pstFile.pinned);
return 0;
}
Output:
rb
@�A��
Zh Efimenko
06/20/2019, 1:26 PMProcess finished with exit code 139 (interrupted by signal 11: SIGSEGV)
Zh Efimenko
06/20/2019, 2:40 PMinternal
modifiers and my library run. But it generates a lot of redundant information on the header.Artyom Degtyarev [JB]
06/21/2019, 9:53 AMinternal
, just as you spotted
2. if I add internal
modifier to the code, and then recompile library, my OLD C-written program starts to print random symbols.
3. But, when I recompile C program, this issue is gone!
So, it would be nice if you can give me more info about the original project, or some non-trivial steps that you made. Currently, it looks more like an occasional mistake rather than K/N bug.Zh Efimenko
06/21/2019, 12:45 PMinternal fun Byte.toUByte(): Int = this.toInt().and(0xFF)
internal fun Short.toUShort(): Int = this.toInt().and(0xFFFF)
internal fun Int.toUInt(): Long = this.toLong().and(0xFFFFFFFF)
internal fun Iterable<SubFolderMetaDto>.toSubFolderMetaNativeList(): SubFolderMetaNativeList {
val destination = SubFolderMetaNativeList()
for (item in this) {
destination.add(item)
}
return destination
}
internal fun Iterable<SubMessageMetaDto>.toSubMessageMetaNativeList(): SubMessageMetaNativeList {
val destination = SubMessageMetaNativeList()
for (item in this) {
destination.add(item)
}
return destination
}
internal fun Iterable<RecipientDto>.toRecipientNativeList(): RecipientNativeList {
val destination = RecipientNativeList()
for (item in this) {
destination.add(item)
}
return destination
}
internal fun Iterable<AttachmentDto>.toAttachmentNativeList(): AttachmentNativeList {
val destination = AttachmentNativeList()
for (item in this) {
destination.add(item)
}
return destination
}
After building my library doesn`t work, but if I remove at least one internal modifier my library works. I followed your advice and I had to do wrappers for kotlin types: List, ByteArrayArtyom Degtyarev [JB]
06/24/2019, 2:14 PM