void ProcessEnumDetail(Enumeration @enum, CXCursor cursor, CXCursor parent) { // unscoped name @enum.UnscopedName = clang.getCursorSpelling(cursor).ToString(); // underlying type CXType underlyingType = clang.getEnumDeclIntegerType(cursor); BasicType type = ClangTraits.ToBasicType(underlyingType); @enum.Type = type; // is scoped @enum.IsEnumClass = clang.EnumDecl_isScoped(cursor) != 0; // check is parent is a class if (OwnerClass_ != null) { Debug.Assert(ClangTraits.IsUserDefinedTypeDecl(parent)); OwnerClass_.AddSubEnum(new SubEnum { Access = ClangTraits.ToAccessSpecifier(clang.getCXXAccessSpecifier(cursor)), Enum = @enum }); } }
private void ProcessMethod(NativeClass thisClass, CXCursor cursor, CXCursor parent) { string name = clang.getCursorSpelling(cursor).ToString(); bool isStataic = clang.CXXMethod_isStatic(cursor) != 0; bool isConst = clang.CXXMethod_isConst(cursor) != 0; bool isVirtual = clang.CXXMethod_isVirtual(cursor) != 0; bool isAbastrct = clang.CXXMethod_isPureVirtual(cursor) != 0; // create method Method memberFunc = new Method(thisClass, name, isStataic, isConst, isVirtual, isAbastrct); OnVisitFunctionParameter func = (FunctionParameter param) => { memberFunc.AddParameter(param); }; // proces result type CXType resultType = clang.getCursorResultType(cursor); memberFunc.ResultType = TypeVisitorHelper.GetNativeType(AST_, resultType); // deep visit children GCHandle delegateHandler = GCHandle.Alloc(func); clang.visitChildren(cursor, ParameterVisitor, new CXClientData((IntPtr)delegateHandler)); // process access specifier memberFunc.Access = ClangTraits.ToAccessSpecifier(clang.getCXXAccessSpecifier(cursor)); // register method thisClass.AddMethod(memberFunc); }
private void ProcessClassDetail( NativeClass thisClass, // this class to parse CXCursor cursor, // current cursor CXType type, // current cursor type CXCursor parent // parent cursor ) { // set unscoped name thisClass.UnscopedName = clang.getCursorSpelling(cursor).ToString(); // set struct or class thisClass.ClassTag = ClangTraits.ToStructOrClass(cursor.kind); // abstract thisClass.IsAbstract = clang.CXXRecord_isAbstract(cursor) != 0; // virtual base thisClass.IsVirtualBase = clang.isVirtualBase(cursor) != 0; // set template instance info if (TemplateHelper.VisitTemplate(cursor, thisClass, AST_)) { thisClass.IsFullSpecialization = true; TypeVisitContext context = new TypeVisitContext(cursor); TemplateHelper.VisitTemplateParameter(cursor, type, thisClass, AST_, context); } // set subclass if (ClangTraits.IsUserDefinedTypeDecl(parent)) { Debug.Assert(OwnerClass_ != null); thisClass.IsEmbedded = true; thisClass.OwnerClass = OwnerClass_; SubClass subClass = new SubClass { Access = ClangTraits.ToAccessSpecifier(clang.getCXXAccessSpecifier(cursor)), Class = thisClass }; OwnerClass_.AddSubClass(subClass); } }
private void ProcessTypeExport(NativeClass thisClass, CXCursor cursor, CXCursor parent) { // createfield context TypeVisitContext context = new TypeVisitContext(cursor); // get field type CXType type = clang.getCursorType(cursor); NativeType nativeType = TypeVisitorHelper.GetNativeType(AST_, type, context); // get field access specifier AccessSpecifier access = ClangTraits.ToAccessSpecifier(clang.getCXXAccessSpecifier(cursor)); // create the exported member type MemberType memberType = new MemberType { Access = access, Type = nativeType }; thisClass.AddMemberType(memberType); }
private void ProcessBaseClass(NativeClass thisClass, CXCursor cursor, CXCursor parent) { // get class name CXType type = clang.getCursorType(cursor); // type visit context TypeVisitContext context = new TypeVisitContext(cursor); // create the base class BaseClass baseClass = new BaseClass { // check access specifier Access = ClangTraits.ToAccessSpecifier(clang.getCXXAccessSpecifier(cursor)), // native class type Type = TypeVisitorHelper.GetNativeType(AST_, type, context), // check is virtual base IsVirtual = clang.isVirtualBase(cursor) != 0 }; // register base class thisClass.AddBaseClass(baseClass); }
private void ProcessField(NativeClass thisClass, CXCursor cursor, CXCursor parent, bool isStatic = false) { // get field name string fieldName = clang.getCursorSpelling(cursor).ToString(); // get field type CXType type = clang.getCursorType(cursor); NativeType nativeType = TypeVisitorHelper.GetNativeType(AST_, type); // get field access specifier AccessSpecifier access = ClangTraits.ToAccessSpecifier(clang.getCXXAccessSpecifier(cursor)); // create field object Field f = new Field { Name = fieldName, Access = access, Type = nativeType, IsStatic = isStatic }; thisClass.AddField(f); }