simd-128 basic support (#3498)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
headers = clang-c/Index.h clang-c/ext.h
|
||||
headers = clang-c/Index.h clang-c/ext.h clang-c/ExtVector.h
|
||||
|
||||
headerFilter = clang-c/**
|
||||
|
||||
|
||||
@@ -1119,3 +1119,6 @@ JNIEXPORT jint JNICALL Java_clang_clang_kniBridge337 (JNIEnv* jniEnv, jclass jcl
|
||||
JNIEXPORT jint JNICALL Java_clang_clang_kniBridge338 (JNIEnv* jniEnv, jclass jclss, jlong p0) {
|
||||
return (jint)clang_Cursor_isObjCConsumingSelfMethod(*(CXCursor*)p0);
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_clang_clang_kniBridge339 (JNIEnv* jniEnv, jclass jclss, jlong p0) {
|
||||
return (jint)clang_isExtVectorType(*(CXType*)p0);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import kotlinx.cinterop.*
|
||||
@CNaturalStruct("data", "private_flags")
|
||||
class CXString(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(16, 8)
|
||||
companion object : CStructVar.Type(16, 8)
|
||||
|
||||
var data: COpaquePointer?
|
||||
get() = memberAt<COpaquePointerVar>(0).value
|
||||
@@ -23,7 +23,7 @@ class CXString(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("Strings", "Count")
|
||||
class CXStringSet(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(16, 8)
|
||||
companion object : CStructVar.Type(16, 8)
|
||||
|
||||
var Strings: CPointer<CXString>?
|
||||
get() = memberAt<CPointerVar<CXString>>(0).value
|
||||
@@ -45,7 +45,7 @@ class CXTranslationUnitImpl(rawPtr: NativePtr) : COpaque(rawPtr)
|
||||
@CNaturalStruct("Filename", "Contents", "Length")
|
||||
class CXUnsavedFile(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
var Filename: CPointer<ByteVar>?
|
||||
get() = memberAt<CPointerVar<ByteVar>>(0).value
|
||||
@@ -63,7 +63,7 @@ class CXUnsavedFile(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("Major", "Minor", "Subminor")
|
||||
class CXVersion(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(12, 4)
|
||||
companion object : CStructVar.Type(12, 4)
|
||||
|
||||
var Major: Int
|
||||
get() = memberAt<IntVar>(0).value
|
||||
@@ -81,7 +81,7 @@ class CXVersion(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("data")
|
||||
class CXFileUniqueID(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
@CLength(3)
|
||||
val data: CArrayPointer<LongVar>
|
||||
@@ -91,7 +91,7 @@ class CXFileUniqueID(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("ptr_data", "int_data")
|
||||
class CXSourceLocation(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
@CLength(2)
|
||||
val ptr_data: CArrayPointer<COpaquePointerVar>
|
||||
@@ -105,7 +105,7 @@ class CXSourceLocation(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("ptr_data", "begin_int_data", "end_int_data")
|
||||
class CXSourceRange(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
@CLength(2)
|
||||
val ptr_data: CArrayPointer<COpaquePointerVar>
|
||||
@@ -123,7 +123,7 @@ class CXSourceRange(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("count", "ranges")
|
||||
class CXSourceRangeList(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(16, 8)
|
||||
companion object : CStructVar.Type(16, 8)
|
||||
|
||||
var count: Int
|
||||
get() = memberAt<IntVar>(0).value
|
||||
@@ -137,7 +137,7 @@ class CXSourceRangeList(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("kind", "amount")
|
||||
class CXTUResourceUsageEntry(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(16, 8)
|
||||
companion object : CStructVar.Type(16, 8)
|
||||
|
||||
var kind: CXTUResourceUsageKind
|
||||
get() = memberAt<CXTUResourceUsageKind.Var>(0).value
|
||||
@@ -151,7 +151,7 @@ class CXTUResourceUsageEntry(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("data", "numEntries", "entries")
|
||||
class CXTUResourceUsage(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
var data: COpaquePointer?
|
||||
get() = memberAt<COpaquePointerVar>(0).value
|
||||
@@ -169,7 +169,7 @@ class CXTUResourceUsage(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("kind", "xdata", "data")
|
||||
class CXCursor(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(32, 8)
|
||||
companion object : CStructVar.Type(32, 8)
|
||||
|
||||
var kind: CXCursorKind
|
||||
get() = memberAt<CXCursorKind.Var>(0).value
|
||||
@@ -187,7 +187,7 @@ class CXCursor(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("Platform", "Introduced", "Deprecated", "Obsoleted", "Unavailable", "Message")
|
||||
class CXPlatformAvailability(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(72, 8)
|
||||
companion object : CStructVar.Type(72, 8)
|
||||
|
||||
val Platform: CXString
|
||||
get() = memberAt(0)
|
||||
@@ -214,7 +214,7 @@ class CXCursorSetImpl(rawPtr: NativePtr) : COpaque(rawPtr)
|
||||
@CNaturalStruct("kind", "data")
|
||||
class CXType(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
var kind: CXTypeKind
|
||||
get() = memberAt<CXTypeKind.Var>(0).value
|
||||
@@ -228,7 +228,7 @@ class CXType(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("int_data", "ptr_data")
|
||||
class CXToken(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
@CLength(4)
|
||||
val int_data: CArrayPointer<IntVar>
|
||||
@@ -242,7 +242,7 @@ class CXToken(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("CursorKind", "CompletionString")
|
||||
class CXCompletionResult(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(16, 8)
|
||||
companion object : CStructVar.Type(16, 8)
|
||||
|
||||
var CursorKind: CXCursorKind
|
||||
get() = memberAt<CXCursorKind.Var>(0).value
|
||||
@@ -256,7 +256,7 @@ class CXCompletionResult(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("Results", "NumResults")
|
||||
class CXCodeCompleteResults(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(16, 8)
|
||||
companion object : CStructVar.Type(16, 8)
|
||||
|
||||
var Results: CPointer<CXCompletionResult>?
|
||||
get() = memberAt<CPointerVar<CXCompletionResult>>(0).value
|
||||
@@ -270,7 +270,7 @@ class CXCodeCompleteResults(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("context", "visit")
|
||||
class CXCursorAndRangeVisitor(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(16, 8)
|
||||
companion object : CStructVar.Type(16, 8)
|
||||
|
||||
var context: COpaquePointer?
|
||||
get() = memberAt<COpaquePointerVar>(0).value
|
||||
@@ -284,7 +284,7 @@ class CXCursorAndRangeVisitor(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("ptr_data", "int_data")
|
||||
class CXIdxLoc(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
@CLength(2)
|
||||
val ptr_data: CArrayPointer<COpaquePointerVar>
|
||||
@@ -298,7 +298,7 @@ class CXIdxLoc(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("hashLoc", "filename", "file", "isImport", "isAngled", "isModuleImport")
|
||||
class CXIdxIncludedFileInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(56, 8)
|
||||
companion object : CStructVar.Type(56, 8)
|
||||
|
||||
val hashLoc: CXIdxLoc
|
||||
get() = memberAt(0)
|
||||
@@ -327,7 +327,7 @@ class CXIdxIncludedFileInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("file", "module", "loc", "isImplicit")
|
||||
class CXIdxImportedASTFileInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(48, 8)
|
||||
companion object : CStructVar.Type(48, 8)
|
||||
|
||||
var file: CXFile?
|
||||
get() = memberAt<CXFileVar>(0).value
|
||||
@@ -348,7 +348,7 @@ class CXIdxImportedASTFileInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("kind", "cursor", "loc")
|
||||
class CXIdxAttrInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(64, 8)
|
||||
companion object : CStructVar.Type(64, 8)
|
||||
|
||||
var kind: CXIdxAttrKind
|
||||
get() = memberAt<CXIdxAttrKindVar>(0).value
|
||||
@@ -364,7 +364,7 @@ class CXIdxAttrInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("kind", "templateKind", "lang", "name", "USR", "cursor", "attributes", "numAttributes")
|
||||
class CXIdxEntityInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(80, 8)
|
||||
companion object : CStructVar.Type(80, 8)
|
||||
|
||||
var kind: CXIdxEntityKind
|
||||
get() = memberAt<CXIdxEntityKind.Var>(0).value
|
||||
@@ -401,7 +401,7 @@ class CXIdxEntityInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("cursor")
|
||||
class CXIdxContainerInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(32, 8)
|
||||
companion object : CStructVar.Type(32, 8)
|
||||
|
||||
val cursor: CXCursor
|
||||
get() = memberAt(0)
|
||||
@@ -410,7 +410,7 @@ class CXIdxContainerInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("attrInfo", "objcClass", "classCursor", "classLoc")
|
||||
class CXIdxIBOutletCollectionAttrInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(72, 8)
|
||||
companion object : CStructVar.Type(72, 8)
|
||||
|
||||
var attrInfo: CPointer<CXIdxAttrInfo>?
|
||||
get() = memberAt<CPointerVar<CXIdxAttrInfo>>(0).value
|
||||
@@ -430,7 +430,7 @@ class CXIdxIBOutletCollectionAttrInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("entityInfo", "cursor", "loc", "semanticContainer", "lexicalContainer", "isRedeclaration", "isDefinition", "isContainer", "declAsContainer", "isImplicit", "attributes", "numAttributes", "flags")
|
||||
class CXIdxDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(128, 8)
|
||||
companion object : CStructVar.Type(128, 8)
|
||||
|
||||
var entityInfo: CPointer<CXIdxEntityInfo>?
|
||||
get() = memberAt<CPointerVar<CXIdxEntityInfo>>(0).value
|
||||
@@ -486,7 +486,7 @@ class CXIdxDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("declInfo", "kind")
|
||||
class CXIdxObjCContainerDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(16, 8)
|
||||
companion object : CStructVar.Type(16, 8)
|
||||
|
||||
var declInfo: CPointer<CXIdxDeclInfo>?
|
||||
get() = memberAt<CPointerVar<CXIdxDeclInfo>>(0).value
|
||||
@@ -500,7 +500,7 @@ class CXIdxObjCContainerDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("base", "cursor", "loc")
|
||||
class CXIdxBaseClassInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(64, 8)
|
||||
companion object : CStructVar.Type(64, 8)
|
||||
|
||||
var base: CPointer<CXIdxEntityInfo>?
|
||||
get() = memberAt<CPointerVar<CXIdxEntityInfo>>(0).value
|
||||
@@ -516,7 +516,7 @@ class CXIdxBaseClassInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("protocol", "cursor", "loc")
|
||||
class CXIdxObjCProtocolRefInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(64, 8)
|
||||
companion object : CStructVar.Type(64, 8)
|
||||
|
||||
var protocol: CPointer<CXIdxEntityInfo>?
|
||||
get() = memberAt<CPointerVar<CXIdxEntityInfo>>(0).value
|
||||
@@ -532,7 +532,7 @@ class CXIdxObjCProtocolRefInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("protocols", "numProtocols")
|
||||
class CXIdxObjCProtocolRefListInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(16, 8)
|
||||
companion object : CStructVar.Type(16, 8)
|
||||
|
||||
var protocols: CPointer<CPointerVar<CXIdxObjCProtocolRefInfo>>?
|
||||
get() = memberAt<CPointerVar<CPointerVar<CXIdxObjCProtocolRefInfo>>>(0).value
|
||||
@@ -546,7 +546,7 @@ class CXIdxObjCProtocolRefListInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("containerInfo", "superInfo", "protocols")
|
||||
class CXIdxObjCInterfaceDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
var containerInfo: CPointer<CXIdxObjCContainerDeclInfo>?
|
||||
get() = memberAt<CPointerVar<CXIdxObjCContainerDeclInfo>>(0).value
|
||||
@@ -564,7 +564,7 @@ class CXIdxObjCInterfaceDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("containerInfo", "objcClass", "classCursor", "classLoc", "protocols")
|
||||
class CXIdxObjCCategoryDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(80, 8)
|
||||
companion object : CStructVar.Type(80, 8)
|
||||
|
||||
var containerInfo: CPointer<CXIdxObjCContainerDeclInfo>?
|
||||
get() = memberAt<CPointerVar<CXIdxObjCContainerDeclInfo>>(0).value
|
||||
@@ -588,7 +588,7 @@ class CXIdxObjCCategoryDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("declInfo", "getter", "setter")
|
||||
class CXIdxObjCPropertyDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
var declInfo: CPointer<CXIdxDeclInfo>?
|
||||
get() = memberAt<CPointerVar<CXIdxDeclInfo>>(0).value
|
||||
@@ -606,7 +606,7 @@ class CXIdxObjCPropertyDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("declInfo", "bases", "numBases")
|
||||
class CXIdxCXXClassDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(24, 8)
|
||||
companion object : CStructVar.Type(24, 8)
|
||||
|
||||
var declInfo: CPointer<CXIdxDeclInfo>?
|
||||
get() = memberAt<CPointerVar<CXIdxDeclInfo>>(0).value
|
||||
@@ -624,7 +624,7 @@ class CXIdxCXXClassDeclInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("kind", "cursor", "loc", "referencedEntity", "parentEntity", "container", "role")
|
||||
class CXIdxEntityRefInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(96, 8)
|
||||
companion object : CStructVar.Type(96, 8)
|
||||
|
||||
var kind: CXIdxEntityRefKind
|
||||
get() = memberAt<CXIdxEntityRefKindVar>(0).value
|
||||
@@ -656,7 +656,7 @@ class CXIdxEntityRefInfo(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("abortQuery", "diagnostic", "enteredMainFile", "ppIncludedFile", "importedASTFile", "startedTranslationUnit", "indexDeclaration", "indexEntityReference")
|
||||
class IndexerCallbacks(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(64, 8)
|
||||
companion object : CStructVar.Type(64, 8)
|
||||
|
||||
var abortQuery: CPointer<CFunction<(CXClientData?, COpaquePointer?) -> Int>>?
|
||||
get() = memberAt<CPointerVar<CFunction<(CXClientData?, COpaquePointer?) -> Int>>>(0).value
|
||||
@@ -694,7 +694,7 @@ class IndexerCallbacks(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
@CNaturalStruct("typeOpaquePtr")
|
||||
class CXTypeAttributes(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
||||
|
||||
companion object : Type(8, 8)
|
||||
companion object : CStructVar.Type(8, 8)
|
||||
|
||||
var typeOpaquePtr: COpaquePointer?
|
||||
get() = memberAt<COpaquePointerVar>(0).value
|
||||
@@ -3838,6 +3838,12 @@ fun clang_Cursor_isObjCConsumingSelfMethod(cursor: CValue<CXCursor>): Int {
|
||||
}
|
||||
}
|
||||
|
||||
fun clang_isExtVectorType(type: CValue<CXType>): Int {
|
||||
memScoped {
|
||||
return kniBridge339(type.getPointer(memScope).rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
val CINDEX_VERSION_MAJOR: Int get() = 0
|
||||
|
||||
val CINDEX_VERSION_MINOR: Int get() = 50
|
||||
@@ -4723,4 +4729,5 @@ private external fun kniBridge335(p0: NativePtr, p1: Int, p2: NativePtr): Unit
|
||||
private external fun kniBridge336(p0: NativePtr): Int
|
||||
private external fun kniBridge337(p0: NativePtr): Int
|
||||
private external fun kniBridge338(p0: NativePtr): Int
|
||||
private val loadLibrary = loadKonanLibrary("clangstubs")
|
||||
private external fun kniBridge339(p0: NativePtr): Int
|
||||
private val loadLibrary = loadKonanLibrary("clangstubs")
|
||||
|
||||
+37
@@ -499,6 +499,43 @@ internal class NativeIndexImpl(val library: NativeLibrary, val verbose: Boolean
|
||||
spelling = clang_getTypeSpelling(type).convertAndDispose().dropConstQualifier()
|
||||
)
|
||||
|
||||
CXType_Unexposed -> {
|
||||
// FIXME Remove this cludge for libclang version >= 9 (CINDEX_VERSION > 55)
|
||||
if (clang_isExtVectorType(type) != 0) {
|
||||
val size = clang_Type_getSizeOf(type)
|
||||
if (size == 16L) {
|
||||
// ExtVector elementType and elementCount are ignored for now but stubs are still needed for
|
||||
// CXType_Vector compatibility. Incoming clang v9 provide CXType_ExtVector compatible with CXType_Vector
|
||||
val spelling = "__attribute__((__vector_size__($size))) float"
|
||||
VectorType(FloatingType(4, "float"), 4, spelling)
|
||||
} else {
|
||||
UnsupportedType
|
||||
}
|
||||
} else {
|
||||
UnsupportedType
|
||||
}
|
||||
}
|
||||
|
||||
CXType_Vector -> {
|
||||
val elementCXType = clang_getElementType(type)
|
||||
val elementType = convertType(elementCXType)
|
||||
val size = clang_Type_getSizeOf(type)
|
||||
val elemSize = clang_Type_getSizeOf(elementCXType)
|
||||
val elementCount = clang_getNumElements(type)
|
||||
assert(size >= elemSize * elementCount && size % elemSize == 0L)
|
||||
|
||||
// Spelling example: `__attribute__((__vector_size__(4 * sizeof(float)))) const float`
|
||||
// Re-generate spelling removing constness and typedefs to limit number of variants for bridge generator
|
||||
// Supposed to be the same (i.e. natively compatible) as clang_getTypeSpelling(type) aka type.name
|
||||
val spelling = "__attribute__((__vector_size__($size))) ${clang_getCanonicalType(elementCXType).name}"
|
||||
|
||||
if (size == 16L) {
|
||||
VectorType(elementType, elementCount.toInt(), spelling)
|
||||
} else {
|
||||
UnsupportedType
|
||||
}
|
||||
}
|
||||
|
||||
CXTypeKind.CXType_Bool -> CBoolType
|
||||
|
||||
else -> UnsupportedType
|
||||
|
||||
+3
-1
@@ -271,6 +271,8 @@ data class IntegerType(val size: Int, val isSigned: Boolean, val spelling: Strin
|
||||
// TODO: floating type is not actually defined entirely by its size.
|
||||
data class FloatingType(val size: Int, val spelling: String) : PrimitiveType
|
||||
|
||||
data class VectorType(val elementType: Type, val elementCount: Int, val spelling: String) : PrimitiveType
|
||||
|
||||
object VoidType : Type
|
||||
|
||||
data class RecordType(val decl: StructDecl) : Type
|
||||
@@ -326,4 +328,4 @@ data class ObjCBlockPointer(
|
||||
val parameterTypes: List<Type>, val returnType: Type
|
||||
) : ObjCPointer()
|
||||
|
||||
object UnsupportedType : Type
|
||||
object UnsupportedType : Type
|
||||
|
||||
@@ -30,6 +30,12 @@ internal val CValue<CXType>.kind: CXTypeKind get() = this.useContents { kind }
|
||||
|
||||
internal val CValue<CXCursor>.kind: CXCursorKind get() = this.useContents { kind }
|
||||
|
||||
internal val CValue<CXCursor>.type: CValue<CXType> get() = clang_getCursorType(this)
|
||||
internal val CValue<CXCursor>.spelling: String get() = clang_getCursorSpelling(this).convertAndDispose()
|
||||
internal val CValue<CXType>.name: String get() = clang_getTypeSpelling(this).convertAndDispose()
|
||||
internal val CXTypeKind.spelling: String get() = clang_getTypeKindSpelling(this).convertAndDispose()
|
||||
internal val CXCursorKind.spelling: String get() = clang_getCursorKindSpelling(this).convertAndDispose()
|
||||
|
||||
internal fun CValue<CXString>.convertAndDispose(): String {
|
||||
try {
|
||||
return clang_getCString(this)!!.toKString()
|
||||
|
||||
@@ -470,4 +470,4 @@ public typealias CArrayPointerVar<T> = CPointerVar<T>
|
||||
/**
|
||||
* The C function.
|
||||
*/
|
||||
public class CFunction<T : Function<*>>(rawPtr: NativePtr) : CPointed(rawPtr)
|
||||
public class CFunction<T : Function<*>>(rawPtr: NativePtr) : CPointed(rawPtr)
|
||||
|
||||
@@ -53,6 +53,9 @@ internal object nativeMemUtils {
|
||||
@TypedIntrinsic(IntrinsicType.INTEROP_READ_PRIMITIVE) external fun getNativePtr(mem: NativePointed): NativePtr
|
||||
@TypedIntrinsic(IntrinsicType.INTEROP_WRITE_PRIMITIVE) external fun putNativePtr(mem: NativePointed, value: NativePtr)
|
||||
|
||||
@TypedIntrinsic(IntrinsicType.INTEROP_READ_PRIMITIVE) external fun getVector(mem: NativePointed): Vector128
|
||||
@TypedIntrinsic(IntrinsicType.INTEROP_WRITE_PRIMITIVE) external fun putVector(mem: NativePointed, value: Vector128)
|
||||
|
||||
// TODO: optimize
|
||||
fun getByteArray(source: NativePointed, dest: ByteArray, length: Int) {
|
||||
val sourceArray = source.reinterpret<ByteVar>().ptr
|
||||
|
||||
@@ -56,6 +56,14 @@ external fun CPointer<*>.getRawValue(): NativePtr
|
||||
|
||||
internal fun CPointer<*>.cPointerToString() = "CPointer(raw=$rawValue)"
|
||||
|
||||
public class Vector128VarOf<T : Vector128>(rawPtr: NativePtr) : CVariable(rawPtr)
|
||||
|
||||
public typealias Vector128Var = Vector128VarOf<Vector128>
|
||||
|
||||
public var <T : Vector128> Vector128VarOf<T>.value: T
|
||||
get() = nativeMemUtils.getVector(this) as T
|
||||
set(value) = nativeMemUtils.putVector(this, value)
|
||||
|
||||
/**
|
||||
* Returns a pointer to C function which calls given Kotlin *static* function.
|
||||
*
|
||||
@@ -106,4 +114,4 @@ internal fun CPointer<*>.cPointerToString() = "CPointer(raw=$rawValue)"
|
||||
|
||||
@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, R> staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21) -> R): CPointer<CFunction<(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21) -> R>>
|
||||
|
||||
@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22, R> staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22) -> R): CPointer<CFunction<(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22) -> R>>
|
||||
@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun <P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22, R> staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22) -> R): CPointer<CFunction<(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22) -> R>>
|
||||
|
||||
+2
@@ -187,6 +187,7 @@ object KotlinTypes {
|
||||
val map by CollectionClassifier
|
||||
|
||||
val nativePtr by InteropType
|
||||
val vector128 by KotlinNativeType
|
||||
|
||||
val cOpaque by InteropType
|
||||
val cOpaquePointer by InteropType
|
||||
@@ -233,6 +234,7 @@ object KotlinTypes {
|
||||
|
||||
private object InteropClassifier : ClassifierAtPackage("kotlinx.cinterop")
|
||||
private object InteropType : TypeAtPackage("kotlinx.cinterop")
|
||||
private object KotlinNativeType : TypeAtPackage("kotlin.native")
|
||||
}
|
||||
|
||||
abstract class KotlinFile(
|
||||
|
||||
+7
@@ -75,6 +75,10 @@ fun PrimitiveType.getKotlinType(declarationMapper: DeclarationMapper): KotlinCla
|
||||
else -> TODO(this.toString())
|
||||
}
|
||||
|
||||
is VectorType -> {
|
||||
/// @todo assert elementType and size here
|
||||
KotlinTypes.vector128
|
||||
}
|
||||
else -> throw NotImplementedError()
|
||||
}
|
||||
|
||||
@@ -373,6 +377,9 @@ fun mirrorPrimitiveType(type: PrimitiveType, declarationMapper: DeclarationMappe
|
||||
8 -> "DoubleVar"
|
||||
else -> TODO(type.toString())
|
||||
}
|
||||
is VectorType -> {
|
||||
"Vector128Var"
|
||||
}
|
||||
else -> TODO(type.toString())
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ enum class BridgedType(val kotlinType: KotlinClassifierType, val convertor: Stri
|
||||
ULONG(KotlinTypes.uLong, "toULong"),
|
||||
FLOAT(KotlinTypes.float, "toFloat"),
|
||||
DOUBLE(KotlinTypes.double, "toDouble"),
|
||||
VECTOR128(KotlinTypes.vector128),
|
||||
NATIVE_PTR(KotlinTypes.nativePtr),
|
||||
OBJC_POINTER(KotlinTypes.nativePtr),
|
||||
VOID(KotlinTypes.unit)
|
||||
|
||||
+2
@@ -46,6 +46,7 @@ class SimpleBridgeGeneratorImpl(
|
||||
BridgedType.ULONG -> "jlong"
|
||||
BridgedType.FLOAT -> "jfloat"
|
||||
BridgedType.DOUBLE -> "jdouble"
|
||||
BridgedType.VECTOR128 -> TODO()
|
||||
BridgedType.NATIVE_PTR -> "jlong"
|
||||
BridgedType.OBJC_POINTER -> TODO()
|
||||
BridgedType.VOID -> "void"
|
||||
@@ -61,6 +62,7 @@ class SimpleBridgeGeneratorImpl(
|
||||
BridgedType.ULONG -> "uint64_t"
|
||||
BridgedType.FLOAT -> "float"
|
||||
BridgedType.DOUBLE -> "double"
|
||||
BridgedType.VECTOR128 -> TODO() // "float __attribute__ ((__vector_size__ (16)))"
|
||||
BridgedType.NATIVE_PTR -> "void*"
|
||||
BridgedType.OBJC_POINTER -> "id"
|
||||
BridgedType.VOID -> "void"
|
||||
|
||||
+3
-2
@@ -91,7 +91,8 @@ private object PredefinedTypesHandler {
|
||||
KotlinTypes.boolean,
|
||||
KotlinTypes.byte, KotlinTypes.short, KotlinTypes.int, KotlinTypes.long,
|
||||
KotlinTypes.uByte, KotlinTypes.uShort, KotlinTypes.uInt, KotlinTypes.uLong,
|
||||
KotlinTypes.float, KotlinTypes.double
|
||||
KotlinTypes.float, KotlinTypes.double,
|
||||
KotlinTypes.vector128
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -173,4 +174,4 @@ private object PredefinedTypesHandler {
|
||||
nativePtrClassifier -> expandNativePtr(platform, nullable)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ fun Type.getStringRepresentation(): String = when (this) {
|
||||
is IntegerType -> this.spelling
|
||||
is FloatingType -> this.spelling
|
||||
|
||||
is VectorType -> this.spelling
|
||||
is PointerType -> getPointerTypeStringRepresentation(this.pointeeType)
|
||||
is ArrayType -> getPointerTypeStringRepresentation(this.elemType)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user