Interop/Indexer: update prebuilts with new interop versions
also port Interop/Runtime/libcallbacks to new interop
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+22
-21
@@ -3,7 +3,7 @@ package org.jetbrains.kotlin.native.interop.indexer
|
||||
import clang.*
|
||||
import clang.CXIdxEntityKind.*
|
||||
import clang.CXTypeKind.*
|
||||
import kotlin_native.interop.*
|
||||
import kotlin_.cinterop.*
|
||||
import java.io.File
|
||||
|
||||
private class StructDeclImpl(spelling: String) : StructDecl(spelling) {
|
||||
@@ -135,11 +135,12 @@ private class NativeIndexImpl : NativeIndex() {
|
||||
CXCursorKind.CXCursor_UnionDecl -> return false
|
||||
|
||||
CXCursorKind.CXCursor_StructDecl -> {
|
||||
val hasAttributes = arena.alloc(Int32Box)
|
||||
val hasAttributes = arena.alloc<CInt32Var>()
|
||||
hasAttributes.value = 0
|
||||
clang_visitChildren(structDefCursor, { cursor, parent, clientData ->
|
||||
clang_visitChildren(structDefCursor, staticCFunction { cursor, parent, clientData ->
|
||||
if (clang_isAttribute(cursor.kind.value) != 0) {
|
||||
clientData.asRef(Int32Box)!!.value = 1
|
||||
val hasAttributes = clientData!!.reinterpret<CInt32Var>().pointed
|
||||
hasAttributes.value = 1
|
||||
}
|
||||
CXChildVisitResult.CXChildVisit_Continue
|
||||
}, hasAttributes.ptr)
|
||||
@@ -220,7 +221,7 @@ private class NativeIndexImpl : NativeIndex() {
|
||||
|
||||
fun indexDeclaration(info: CXIdxDeclInfo) {
|
||||
val cursor = info.cursor
|
||||
val entityInfo = info.entityInfo.value!!
|
||||
val entityInfo = info.entityInfo.pointed!!
|
||||
val entityName = entityInfo.name.value?.asCString()?.toString()
|
||||
val kind = entityInfo.kind.value
|
||||
|
||||
@@ -230,7 +231,7 @@ private class NativeIndexImpl : NativeIndex() {
|
||||
val type = convertType(clang_getCursorType(cursor, arena))
|
||||
val offset = clang_Cursor_getOffsetOfField(cursor)
|
||||
|
||||
val container = info.semanticContainer.value!!
|
||||
val container = info.semanticContainer.pointed!!
|
||||
val structDef = getStructDeclAt(container.cursor).def!!
|
||||
structDef.fields.add(Field(name, type, offset))
|
||||
}
|
||||
@@ -265,7 +266,7 @@ private class NativeIndexImpl : NativeIndex() {
|
||||
}
|
||||
|
||||
CXIdxEntity_EnumConstant -> {
|
||||
val container = info.semanticContainer.value!!
|
||||
val container = info.semanticContainer.pointed!!
|
||||
val name = entityName!!
|
||||
val value = clang_getEnumConstantDeclValue(info.cursor)
|
||||
|
||||
@@ -294,11 +295,11 @@ fun CXString.convertAndDispose(): String {
|
||||
|
||||
fun buildNativeIndexImpl(headerFile: File, args: List<String>): NativeIndex {
|
||||
// TODO: dispose all allocated memory and resources
|
||||
val args1 = args.map { CString.fromString(it)!!.asCharPtr() }.toTypedArray()
|
||||
val args1 = args.map { CString.fromString(it, nativeHeap)!!.asCharPtr() }.toTypedArray()
|
||||
|
||||
val index = clang_createIndex(0, 0)
|
||||
val indexAction = clang_IndexAction_create(index)
|
||||
val callbacks = malloc(IndexerCallbacks.Companion)
|
||||
val callbacks = nativeHeap.alloc<IndexerCallbacks>()
|
||||
|
||||
val res = NativeIndexImpl()
|
||||
try {
|
||||
@@ -307,23 +308,23 @@ fun buildNativeIndexImpl(headerFile: File, args: List<String>): NativeIndex {
|
||||
|
||||
try {
|
||||
with(callbacks) {
|
||||
abortQuery.setStatic(null)
|
||||
diagnostic.setStatic(null)
|
||||
enteredMainFile.setStatic(null)
|
||||
ppIncludedFile.setStatic(null)
|
||||
importedASTFile.setStatic(null)
|
||||
startedTranslationUnit.setStatic(null)
|
||||
indexDeclaration.setStatic { clientData, info ->
|
||||
abortQuery.value = null
|
||||
diagnostic.value = null
|
||||
enteredMainFile.value = null
|
||||
ppIncludedFile.value = null
|
||||
importedASTFile.value = null
|
||||
startedTranslationUnit.value = null
|
||||
indexDeclaration.value = staticCFunction { clientData, info ->
|
||||
val index = StableObjPtr.fromValue(clientData!!).get() as NativeIndexImpl
|
||||
index.indexDeclaration(info!!)
|
||||
index.indexDeclaration(info!!.pointed)
|
||||
}
|
||||
indexEntityReference.setStatic(null)
|
||||
indexEntityReference.value = null
|
||||
}
|
||||
|
||||
val commandLineArgs = if (args1.size != 0) mallocNativeArrayOf(Int8Box.Companion, *args1)[0] else null
|
||||
val commandLineArgs = if (args1.size != 0) nativeHeap.allocArrayOfPointersTo(*args1)[0].ptr else null
|
||||
|
||||
clang_indexSourceFile(indexAction, clientData, callbacks, IndexerCallbacks.size, 0, headerFile.path,
|
||||
commandLineArgs, args1.size, null, 0, null, 0)
|
||||
clang_indexSourceFile(indexAction, clientData, callbacks.ptr, IndexerCallbacks.size.toInt(),
|
||||
0, headerFile.path, commandLineArgs, args1.size, null, 0, null, 0)
|
||||
|
||||
|
||||
return res
|
||||
|
||||
@@ -4,101 +4,101 @@
|
||||
#include <ffi.h>
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeVoid
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeVoid(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeVoid(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_void;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeUInt8
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeUInt8(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeUInt8(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_uint8;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeSInt8
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeSInt8(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeSInt8(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_sint8;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeUInt16
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeUInt16(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeUInt16(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_uint16;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeSInt16
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeSInt16(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeSInt16(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_sint16;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeUInt32
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeUInt32(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeUInt32(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_uint32;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeSInt32
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeSInt32(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeSInt32(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_sint32;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeUInt64
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeUInt64(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeUInt64(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_uint64;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeSInt64
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeSInt64(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeSInt64(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_sint64;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypePointer
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypePointer(JNIEnv *env, jclass cls) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypePointer(JNIEnv *env, jclass cls) {
|
||||
return (jlong) &ffi_type_pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiTypeStruct0
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeStruct0(JNIEnv *env, jclass cls, jlong elements) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiTypeStruct0(JNIEnv *env, jclass cls, jlong elements) {
|
||||
ffi_type* res = malloc(sizeof(ffi_type));
|
||||
if (res != NULL) {
|
||||
res->size = 0;
|
||||
@@ -110,11 +110,11 @@ JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiTypeStruct0(J
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiCreateCif0
|
||||
* Signature: (IJJ)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiCreateCif0(JNIEnv *env, jclass cls, jint nArgs, jlong rType, jlong argTypes) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiCreateCif0(JNIEnv *env, jclass cls, jint nArgs, jlong rType, jlong argTypes) {
|
||||
ffi_cif* res = malloc(sizeof(ffi_cif));
|
||||
if (res != NULL) {
|
||||
ffi_status status = ffi_prep_cif(res, FFI_DEFAULT_ABI, nArgs, (ffi_type*)rType, (ffi_type**)argTypes);
|
||||
@@ -166,7 +166,7 @@ static void ffi_fun(ffi_cif *cif, void *ret, void **args, void *user_data) {
|
||||
static jmethodID ffiFunImpl0 = NULL;
|
||||
static jclass cls = NULL;
|
||||
if (ffiFunImpl0 == NULL) {
|
||||
jclass clsLocal = (*env)->FindClass(env, "kotlin_native/interop/CallbacksKt");
|
||||
jclass clsLocal = (*env)->FindClass(env, "kotlin_/cinterop/JvmCallbacksKt");
|
||||
checkException(env);
|
||||
assert(clsLocal != NULL);
|
||||
|
||||
@@ -184,11 +184,11 @@ static void ffi_fun(ffi_cif *cif, void *ret, void **args, void *user_data) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: ffiCreateClosure0
|
||||
* Signature: (JLjava/lang/Object;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiCreateClosure0(JNIEnv *env, jclass cls, jlong ffiCif, jobject userData) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_ffiCreateClosure0(JNIEnv *env, jclass cls, jlong ffiCif, jobject userData) {
|
||||
jobject userDataGlobalRef = (*env)->NewGlobalRef(env, userData);
|
||||
if (userDataGlobalRef == NULL) {
|
||||
return (jlong)0;
|
||||
@@ -211,29 +211,29 @@ JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_ffiCreateClosure
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: newGlobalRef
|
||||
* Signature: (Ljava/lang/Object;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1native_interop_CallbacksKt_newGlobalRef(JNIEnv *env, jclass cls, jobject obj) {
|
||||
JNIEXPORT jlong JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_newGlobalRef(JNIEnv *env, jclass cls, jobject obj) {
|
||||
jobject res = (*env)->NewGlobalRef(env, obj);
|
||||
return (jlong) res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: derefGlobalRef
|
||||
* Signature: (J)Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_kotlin_1native_interop_CallbacksKt_derefGlobalRef(JNIEnv *env, jclass cls, jlong ref) {
|
||||
JNIEXPORT jobject JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_derefGlobalRef(JNIEnv *env, jclass cls, jlong ref) {
|
||||
return (jobject) ref;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: kotlin_native_interop_CallbacksKt
|
||||
* Class: kotlin__cinterop_JvmCallbacksKt
|
||||
* Method: deleteGlobalRef
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_kotlin_1native_interop_CallbacksKt_deleteGlobalRef(JNIEnv *env, jclass cls, jlong ref) {
|
||||
JNIEXPORT void JNICALL Java_kotlin_1_cinterop_JvmCallbacksKt_deleteGlobalRef(JNIEnv *env, jclass cls, jlong ref) {
|
||||
(*env)->DeleteGlobalRef(env, (jobject) ref);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user