bool TraverseType(clang::QualType type)
 {
     if (type.isNull())
     {
         return PARENT::TraverseType(type);
     }
     auto node = std::make_unique<GenericAstNode>();
     //node->myType = d;
     node->name = type->getTypeClassName();
     auto nodePtr = node.get();
     myStack.back()->attach(std::move(node));
     myStack.push_back(nodePtr);
     auto res = PARENT::TraverseType(type);
     myStack.pop_back();
     return res;
 }
std::string UWrapperGeneratorVB6Declare::ClangTypeToVB6(const clang::QualType& type, bool* success, bool canHaveRef, bool* isRef /*= 0*/)
{
    if (isRef)
        *isRef = false;

    if (type->isFunctionPointerType()) {
        return "Long";
    }
    else if (type->getTypeClass() == clang::Type::Builtin) {
        const clang::BuiltinType* builtInType = type->getAs<clang::BuiltinType>();
        return ClangBuiltinTypeToVB6(builtInType, success);
    }
    else if (type->getTypeClass() == clang::Type::Pointer) {
        const clang::PointerType* pointerType = type->getAs<clang::PointerType>();
        const clang::QualType& pointeeType = pointerType->getPointeeType();
        if (pointeeType->getTypeClass() == clang::Type::Builtin) {
            const clang::BuiltinType* pointeeTypeBuiltin = pointeeType->getAs<clang::BuiltinType>();
            switch (pointeeTypeBuiltin->getKind()) {
            case clang::BuiltinType::SChar:
            case clang::BuiltinType::Char_S:
            case clang::BuiltinType::UChar:
            case clang::BuiltinType::Char_U: return "String"; //char* --> String
            case clang::BuiltinType::Void: return "Long"; // void* --> Long
            default:
                if (m_ptrToLong)
                    return "Long";

                if (canHaveRef) {
                    if (isRef)
                        *isRef = true;
                    return ClangBuiltinTypeToVB6(pointeeTypeBuiltin, success);
                }
            }
        }
        if (m_ptrToLong)
            return "Long";

        std::string conv = ClangTypeToVB6(pointeeType, success, false);
        if (canHaveRef) {
            if (isRef)
                *isRef = true;
            return conv;
        }
        return "Long";
    }
    else if (type->getTypeClass() == clang::Type::Typedef) {
        return ClangTypeToVB6(type->getAs<clang::TypedefType>()->desugar(), success, canHaveRef, isRef);
    }
    else if (type->getTypeClass() == clang::Type::Elaborated) {
        return ClangTypeToVB6(type->getAs<clang::ElaboratedType>()->desugar(), success, canHaveRef, isRef);
    }
    else if (type->getTypeClass() == clang::Type::Paren) {
        return ClangTypeToVB6(type->getAs<clang::ParenType>()->desugar(), success, canHaveRef, isRef);
    }
    else if (type->getTypeClass() == clang::Type::Enum) {
        const clang::EnumType* enumType = type->getAs<clang::EnumType>();
        if (m_collectedEnums.find(enumType->getDecl()) != m_collectedEnums.end()) {
            return clang::QualType(enumType, 0).getAsString();
        }
    }
    else if (type->getTypeClass() == clang::Type::Record) {
        const clang::RecordType* recType = type->getAs<clang::RecordType>();
        if (m_collectedRecords.find(recType->getDecl()) != m_collectedRecords.end())
            return recType->getDecl()->getNameAsString();
    }
    if (success)
        *success = false;

    
    std::cout << type->getTypeClassName() << std::endl;
    type->dump();
    

    return "<Unsupported>";
}