Example #1
0
 public UnknownAnnotation(string text, FilePosition filePosition) : base(text, filePosition)
 {
 }
Example #2
0
 public OverloadAnnotation(string text, FilePosition filePosition) : base(text, filePosition)
 {
 }
Example #3
0
 public OutParameterAnnotation(string text, FilePosition filePosition, WarningList warnings)
     : base(text, filePosition, warnings)
 {
 }
Example #4
0
 public AttributeAnnotation(string text, FilePosition filePosition, WarningList warnings)
     : base(text, filePosition, warnings)
 {
 }
Example #5
0
 public ConstantAnnotation(string text, FilePosition filePosition, WarningList warnings)
     : base(text, filePosition, warnings)
 {
 }
Example #6
0
        public void Parse(DirectoryInfo moaiDirectory)
        {
            // Check that the input directory looks like the Moai main directory
            if (!moaiDirectory.GetDirectoryInfo(@"src\moai-core").Exists)
            {
                throw new PlainTextException(string.Format("Path '{0}' does not appear to be the base directory of a Moai source copy.", moaiDirectory));
            }

            // Initialize warning list
            Warnings = new WarningList();

            // Get Moai version
            MoaiVersionInfo = new MoaiVersionInfo(moaiDirectory);
            statusCallback(string.Format("Found {0}.", MoaiVersionInfo));

            // Initialize type list with primitive types
            types = new TypeCollection(includePrimitives: true, includeVariant: true);

            // Parse Moai classes and store them by class name
            statusCallback("Parsing Moai classes.");
            ParseMoaiCodeFiles(moaiDirectory);



            // Mark registered classes as scriptable
            statusCallback("Checking which classes are registered to be scriptable from Lua.");
            MarkScriptableClasses(moaiDirectory);


            // MOAILuaObject is not documented, probably because it would mess up
            // the Doxygen-generated documentation. Use dummy code instead.
            statusCallback("Adding hard-coded documentation for MOAILuaObject base class.");
            FilePosition dummyFilePosition = new FilePosition(new FileInfo("MOAILuaObject dummy code"));

            FileParser.ParseMoaiCodeFile(MOAILuaObject.DummyCode, dummyFilePosition, types, Warnings);

            // Make sure every class directly or indirectly inherits from MOAILuaObject
            MoaiClass luaObjectClass = (MoaiClass)types.GetOrCreate("MOAILuaObject", null);

            foreach (MoaiClass moaiClass in types.OfType <MoaiClass>().Where(x => x.IsScriptable))
            {
                if (!(moaiClass.AncestorClasses.Contains(luaObjectClass)) && moaiClass != luaObjectClass)
                {
                    moaiClass.BaseClasses.Add(luaObjectClass);
                }
                // Make sure every class has a new
                if (moaiClass.Members.FirstOrDefault(x => x.Name == "new") == null && moaiClass.ClassPosition != null)
                {
                    moaiClass.Members.Add(
                        new Method()
                    {
                        OutParameterSignature = new MoaiParsing.Parameter()
                        {
                            Name = "object", Type = moaiClass.Name
                        },
                        Name           = "new",
                        Description    = "Create new instance of " + moaiClass.Name,
                        OwningClass    = moaiClass,
                        Body           = "",
                        MethodPosition = new MethodPosition(moaiClass.ClassPosition, "_new"),
                        Overloads      = { new MethodOverload()
                                           {
                                               InParameters  =   {                     },
                                               IsStatic      = true,
                                               OutParameters =   { new OutParameter()
                                                                   {
                                                                       Description = "Result", Name = "object", Type = moaiClass
                                                                   } }
                                           } }
                    }
                        );
                }
            }

            // Perform additional checks that do not alter the code graph
            var checks = GetChecks();

            statusCallback(string.Format("Performing {0} additional code checks.", checks.Length));
            PerformChecks(checks, moaiDirectory);
        }