Exemple #1
0
        internal string ParseStructureFunctions(StructureDefinition def, string[] lines, int startIndex)
        {
            int    funcIndex        = startIndex + 1;
            string funcDef          = lines[funcIndex];
            bool   isCppDefinitions = false;

            // Read structure function signatures.
            while (!funcDef.StartsWith("};"))
            {
                if (funcDef.Contains("#ifdef __cplusplus"))
                {
                    isCppDefinitions = true;
                }
                else if (funcDef.Contains("#endif"))
                {
                    isCppDefinitions = false;
                }

                if (!string.IsNullOrEmpty(funcDef) &&
                    funcDef.Contains("(") && // Fields won't have it.
                    !isCppDefinitions)
                {
                    FunctionDefinition func = new FunctionDefinition();
                    func.ReturnType = this.ParseFunctionReturnType(funcDef);
                    func.Name       = this.ParseFunctionName(funcDef);

                    if (!this.MethodRegistered(func, def))
                    {
                        this.ParseFunctionParameters(func, funcIndex, lines, funcDef);

                        if (!func.ReturnType.Contains("(") &&
                            !string.IsNullOrEmpty(func.Name))
                        {
                            def.Functions.Add(func);
                        }
                    }

                    func.Clean();
                }

                funcIndex++;
                funcDef = lines[funcIndex];
            }

            return(funcDef);
        }