Improve determining which C enum constants are explicitly defined (#3384)
Improve determining which C enum constants are explicitly defined
This commit is contained in:
committed by
Nikolay Igotti
parent
7daa36cc4d
commit
b7ad1d9907
+1
-1
@@ -276,7 +276,7 @@ internal class NativeIndexImpl(val library: NativeLibrary, val verbose: Boolean
|
||||
val name = clang_getCursorSpelling(childCursor).convertAndDispose()
|
||||
val value = clang_getEnumConstantDeclValue(childCursor)
|
||||
|
||||
val constant = EnumConstant(name, value, isExplicitlyDefined = !childCursor.isLeaf())
|
||||
val constant = EnumConstant(name, value, isExplicitlyDefined = childCursor.hasExpressionChild())
|
||||
enumDef.constants.add(constant)
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -201,15 +201,19 @@ fun StructDef.fieldsHaveDefaultAlignment(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
internal fun CValue<CXCursor>.isLeaf(): Boolean {
|
||||
var hasChildren = false
|
||||
internal fun CValue<CXCursor>.hasExpressionChild(): Boolean {
|
||||
var result = false
|
||||
|
||||
visitChildren(this) { _, _ ->
|
||||
hasChildren = true
|
||||
CXChildVisitResult.CXChildVisit_Break
|
||||
visitChildren(this) { cursor, _ ->
|
||||
if (clang_isExpression(cursor.kind) != 0) {
|
||||
result = true
|
||||
CXChildVisitResult.CXChildVisit_Break
|
||||
} else {
|
||||
CXChildVisitResult.CXChildVisit_Continue
|
||||
}
|
||||
}
|
||||
|
||||
return !hasChildren
|
||||
return result
|
||||
}
|
||||
|
||||
internal fun List<String>.toNativeStringArray(scope: AutofreeScope): CArrayPointer<CPointerVar<ByteVar>> {
|
||||
|
||||
Reference in New Issue
Block a user