private static void ProcessMemberPointer(AST ast, NativeType type, CXType cxType, TypeVisitContext context) { CXType classType = clang.Type_getClassType(cxType); string className = clang.getTypeSpelling(classType).ToString(); NativeClass nativeClass = ast.GetClass(className); CXType pointeeType = clang.getPointeeType(cxType); if (ClangTraits.IsFunction(pointeeType)) { type.SetPMF(new MemberFunctionPointer { Class = nativeClass, Function = GetFunctionProto(ast, pointeeType, context) }); } else { type.SetPMD(new MemberDataPointer { Class = nativeClass, Data = GetNativeType(ast, pointeeType, context) }); } }
public bool DoVisit(CXCursor cursor, CXCursor parent) { // get class type CXType type = clang.getCursorType(cursor); // get class name string className = clang.getTypeSpelling(type).ToString(); // get class object NativeClass @class = AST_.GetClass(className); // if a class is from template instatiation or a type declaration @class.IsClassEntity = true; // is definition bool isDefinition = clang.isCursorDefinition(cursor) != 0; // dealing with defition and unsettled types if ([email protected] && isDefinition) { @class.Parsed = true; //proces class detail ProcessClassDetail(@class, cursor, type, parent); // create IntPtr for context GCHandle classHandle = GCHandle.Alloc(@class); // visit children clang.visitChildren(cursor, Visitor, new CXClientData((IntPtr)classHandle)); } return(true); }
private static void ProcessTypeEntity( AST ast, NativeType type, CXType cxType, TypeVisitContext context) { type.IsConst = ClangTraits.IsConst(cxType); if (ClangTraits.IsBuiltInType(cxType)) { type.SetBuiltin(ClangTraits.ToBasicType(cxType)); } else { CXCursor cursor = clang.getTypeDeclaration(cxType); CXType theType = clang.getCursorType(cursor); string removeQualifierName = clang.getTypeSpelling(theType).ToString(); if (ClangTraits.IsEnum(cxType)) { type.SetEnum(ast.GetEnum(removeQualifierName)); } else if (ClangTraits.IsFunction(cxType)) { type.SetFunction(GetFunctionProto(ast, cxType, context)); } else if (ClangTraits.IsUserDefiendType(cxType)) { NativeClass nativeClass = ast.GetClass(removeQualifierName); // if native class is parsed already, the native class is a full specialization // or the native class is a instantiation of a template or partial specialization if (!nativeClass.IsClassEntity && !nativeClass.Parsed) { nativeClass.Parsed = true; if (TemplateHelper.VisitTemplate(cursor, nativeClass, ast)) { TemplateHelper.VisitTemplateParameter(cursor, theType, nativeClass, ast, context); } } type.SetClass(nativeClass); } } }