diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-09-10 15:23:38 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-09-17 14:07:15 +0200 |
| commit | f0a7b00d63ca8a4f6649fd710c75918dc66faa9b (patch) | |
| tree | d36e6855afef87d70efccb078b135382b359b1ce /sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp | |
| parent | a5e2d40f9c729988f0e763c275dbbc2e6cf3fefe (diff) | |
shiboken6/code model: Add a type category roughly modelled after libclang's CXType_Kind
Use what clang considers to be the "canonical" type for a category
enumeration. This is useful for follow-up changes to simplify
type resolution.
Pick-to: 6.10
Change-Id: Ic9f23308cf6bf4b5b29f3c2fff119cba58f3ac1e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp')
| -rw-r--r-- | sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp index a3be50249..cc2924287 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp @@ -524,6 +524,27 @@ void BuilderPrivate::addTemplateInstantiations(const CXType &type, typeName->remove(pos.first, pos.second - pos.first); } +static TypeCategory typeCategoryFromClang(CXTypeKind k) +{ + switch (k) { + case CXType_Void: + return TypeCategory::Void; + case CXType_Enum: + return TypeCategory::Enum; + case CXType_Pointer: + case CXType_BlockPointer: + return TypeCategory::Pointer; + case CXType_FunctionNoProto: + case CXType_FunctionProto: + return TypeCategory::Function; + default: + break; + } + if (k >= CXType_FirstBuiltin && k <= CXType_LastBuiltin) + return TypeCategory::Builtin; + return TypeCategory::Other; +} + TypeInfo BuilderPrivate::createTypeInfoUncached(const CXType &type, bool *cacheable) const { @@ -533,6 +554,7 @@ TypeInfo BuilderPrivate::createTypeInfoUncached(const CXType &type, if (argCount >= 0) { TypeInfo result = createTypeInfoUncached(clang_getResultType(pointeeType), cacheable); + result.setTypeCategory(TypeCategory::Pointer); result.setFunctionPointer(true); for (int a = 0; a < argCount; ++a) result.addArgument(createTypeInfoUncached(clang_getArgType(pointeeType, unsigned(a)), @@ -542,6 +564,7 @@ TypeInfo BuilderPrivate::createTypeInfoUncached(const CXType &type, } TypeInfo typeInfo; + typeInfo.setTypeCategory(typeCategoryFromClang(clang_getCanonicalType(type).kind)); CXType nestedType = type; for (; isArrayType(nestedType.kind); nestedType = clang_getArrayElementType(nestedType)) { |
