Ejemplo n.º 1
0
        public override bool VisitCppInterface(CppInterface cppInterface)
        {
            Declaration unitDecl;

            cppElementToDeclarationMapping.TryGetValue(cppInterface.ParentInclude, out unitDecl);
            TranslationUnit unit = unitDecl != null ? unitDecl as TranslationUnit : FindDeclParent <TranslationUnit>(cppInterface.ParentInclude);

            Namespace @namespace = null;
            Class     @interface = null;

            // Check if we have an namespace
            if (!string.IsNullOrEmpty(cppInterface.Namespace))
            {
                @namespace = unit.FindCreateNamespace(cppInterface.Namespace.TrimStart(':'));
                @interface = @namespace.FindClass(cppInterface.Name, true, true);
            }
            else
            {
                @interface = unit.FindClass(cppInterface.Name, true, true);
            }

            @interface.Type = ClassType.Interface;

            // Check if we have an base class
            if (!string.IsNullOrEmpty(cppInterface.ParentName))
            {
                Class baseClass = null;
                if (@namespace != null)
                {
                    baseClass = @namespace.FindClass(cppInterface.ParentName, true, true);
                }
                else
                {
                    baseClass = unit.FindClass(cppInterface.ParentName, true, true);
                }

                // Set type of base class
                baseClass.Type = baseClass.Name.StartsWith("I") ? ClassType.Interface : ClassType.ValueType;

                // Add type tag
                @interface.Bases.Add(new BaseClassSpecifier
                {
                    Access = AccessSpecifier.Public,
                    Type   = new TagType(baseClass)
                });
            }

            cppElementToDeclarationMapping.Add(cppInterface, @interface);
            return(base.VisitCppInterface(cppInterface));
        }