Esempio n. 1
0
        public override bool VisitCppMethod(CppMethod cppMethod)
        {
            Declaration declaration;

            cppElementToDeclarationMapping.TryGetValue(cppMethod.Parent, out declaration);

            switch (cppMethod.GetType().Name)
            {
            case "CppFunction":
                TranslationUnit unit     = declaration != null ? declaration as TranslationUnit : FindDeclParent <TranslationUnit>(cppMethod.Parent);
                Function        function = new Function();

                function.Name       = cppMethod.Name;
                function.Namespace  = unit.FindNamespace(cppMethod.Namespace);
                function.ReturnType = GetQualifiedType(cppMethod.ReturnType);

                unit.Functions.Add(function);
                cppElementToDeclarationMapping.Add(cppMethod, function);
                break;

            default:
                Class  @class = declaration != null ? declaration as Class : FindDeclParent <Class>(cppMethod.Parent);
                Method method = new Method();

                method.Kind      = CXXMethodKind.Normal;
                method.Name      = cppMethod.Name;
                method.Namespace = @class.Namespace;

                try
                {
                    method.Access = (AccessSpecifier)Enum.Parse(typeof(AccessSpecifier), cppMethod.Access, true);
                }
                catch (ArgumentException)
                {
                    method.Access = AccessSpecifier.Internal;
                }

                method.IsOverride = cppMethod.Override;
                method.IsVirtual  = cppMethod.Virtual;

                method.ReturnType = GetQualifiedType(cppMethod.ReturnType);

                @class.Methods.Add(method);
                cppElementToDeclarationMapping.Add(cppMethod, method);
                break;
            }

            return(base.VisitCppMethod(cppMethod));
        }
Esempio n. 2
0
 public static Namespace Namespace(this TranslationUnit unit, string name)
 {
     return(unit.FindNamespace(name));
 }