Exemple #1
0
        public override void Process(FileParser fileParser)
        {
            Line = fileParser.Lines[fileParser.CurrentLineCount];

            string name = null;

            if (ParamsList != null && ParamsList.Count > 0)
            {
                for (int i = 0; i < ParamsList.Count; i++)
                {
                    if (ParamsList[i] is NameParam nameParam)
                    {
                        name = nameParam.Value;

                        ParamsList.RemoveAt(i);

                        break;
                    }
                }

                if (ParamsList.Count == 0)
                {
                    ParamsList = null;
                }
            }

            Match  splitMatch = GetRegex().Match(Line);
            string result     = Line.Substring(splitMatch.Index, Line.Length - splitMatch.Index);

            ConVarData = NeoDoc.GetEntriesFromString(result, out _).ToArray();
            ConVarName = (name ?? ConVarData[0]).Trim('"');
        }
Exemple #2
0
        public override void Process(FileParser fileParser)
        {
            Line = fileParser.Lines[fileParser.CurrentLineCount];

            string name = null;

            if (ParamsList != null && ParamsList.Count > 0)
            {
                for (int i = 0; i < ParamsList.Count; i++)
                {
                    if (ParamsList[i] is NameParam nameParam)
                    {
                        name = nameParam.Value;

                        ParamsList.RemoveAt(i);

                        break;
                    }
                }

                if (ParamsList.Count == 0)
                {
                    ParamsList = null;
                }
            }

            Match splitMatch = GetRegex().Match(Line);

            if (splitMatch.NextMatch().Success)             // there are multiple hooks in this line
            {
                NeoDoc.WriteErrors("Multiple datastructures found", null, fileParser.relPath, fileParser.CurrentLineCount + 1, (int)NeoDoc.ERROR_CODES.MULTIPLE_DS_IN_LINE);
            }

            string result = Line.Substring(splitMatch.Index, Line.Length - splitMatch.Index);

            bool mode = new Regex(@"\s*hook\.Run\s*\(").Match(Line).Success;             // if false, "hook.Call(" is found

            List <string> tmpData = NeoDoc.GetEntriesFromString(result, out _);

            HookName = GlobalWrapper + ":" + (name ?? tmpData[0]).Trim('"');

            HookData = HookName + "(" + string.Join(", ", tmpData.GetRange(mode ? 1 : 2, tmpData.Count - (mode ? 1 : 2)).ToArray()) + ")";             // "hook.Call( string eventName, table gamemodeTable, vararg args )" or "hook.Run( string eventName, vararg args )"
        }
Exemple #3
0
        public override void Check()
        {
            List <string>     expectedParams = NeoDoc.GetEntriesFromString(FunctionData, out _);
            List <ParamParam> paramParams    = new List <ParamParam>();

            if (ParamsList != null)
            {
                foreach (Param param in ParamsList)
                {
                    if (param is ParamParam paramParam)
                    {
                        paramParams.Add(paramParam);
                    }
                }
            }

            if (paramParams.Count != expectedParams.Count)
            {
                List <string> errors = new List <string>()
                {
                    "In '" + GetName() + "' datastructure ('" + FunctionData + "'), detected params (" + paramParams.Count + "): "
                };

                foreach (ParamParam paramParam in paramParams)
                {
                    errors.Add("- '" + paramParam.Name + "'");
                }

                errors.Add("Expected Params (" + expectedParams.Count + "): ");

                foreach (string paramParamName in expectedParams)
                {
                    errors.Add("- '" + paramParamName + "'");
                }

                NeoDoc.WriteErrors("Param mismatch", errors, FoundPath, FoundLine, (int)NeoDoc.ERROR_CODES.PARAM_MISMATCH);
            }
        }
Exemple #4
0
        public override void Process(FileParser fileParser)
        {
            if (Ignore)
            {
                return;
            }

            string[] typs    = null;
            string   typDesc = null;
            string   name    = null;
            bool     local   = false;

            if (ParamsList != null)
            {
                for (int i = 0; i < ParamsList.Count; i++)
                {
                    List <Param> copyParamsList = new List <Param>();
                    Param        currentParam   = ParamsList[i];

                    if (currentParam is AccessorParam accessorParam)
                    {
                        typs    = accessorParam.Typs;
                        typDesc = accessorParam.Description;
                    }
                    else if (currentParam is NameParam nameParam)
                    {
                        name = nameParam.Value;
                    }
                    else if (currentParam is LocalParam)
                    {
                        local = true;
                    }
                    else
                    {
                        copyParamsList.Add(currentParam);
                    }
                }

                if (ParamsList.Count == 0)
                {
                    ParamsList = null;
                }
            }

            if (local)
            {
                Ignore = true;
            }

            string line = fileParser.Lines[fileParser.CurrentLineCount];

            if (typs == null)
            {
                NeoDoc.WriteErrors("Missing essential param", new List <string> {
                    "Missing '@accessor' in '" + GetName() + "' datastructure"
                }, fileParser.relPath, fileParser.CurrentLineCount + 1, (int)NeoDoc.ERROR_CODES.MISSING_ESSENTIAL_PARAMS);
            }

            Match splitMatch = GetRegex().Match(line);

            List <string> tmpData = NeoDoc.GetEntriesFromString(line.Substring(splitMatch.Index, line.Length - splitMatch.Index), out _);

            string wrapperName  = tmpData[0].Trim();
            string varName      = tmpData[1].Trim('"');
            string funcPartName = tmpData[2].Trim('"');

            // create a setter func
            Function setterFunc = new Function
            {
                // set meta information
                FoundLine = fileParser.CurrentLineCount + 1,
                FoundPath = fileParser.relPath
            };

            setterFunc.Line         = line;
            setterFunc.Local        = local;
            setterFunc.FunctionData = line;
            setterFunc.Name         = wrapperName + ":" + "Set" + (name ?? funcPartName);

            List <Param> _tmpList;

            if (ParamsList == null)
            {
                _tmpList = new List <Param>();
            }
            else
            {
                _tmpList = new List <Param>(ParamsList);
            }

            setterFunc.ParamsList = _tmpList;

            setterFunc.ParamsList.Add(new ParamParam()
            {
                Name        = varName,
                Typs        = typs,
                Description = typDesc
            });

            // create a getter func
            Function getterFunc = new Function
            {
                // set meta information
                FoundLine = fileParser.CurrentLineCount + 1,
                FoundPath = fileParser.relPath
            };

            getterFunc.Line         = line;
            getterFunc.Local        = local;
            getterFunc.FunctionData = line;
            getterFunc.Name         = wrapperName + ":" + "Get" + (name ?? funcPartName);

            if (ParamsList == null)
            {
                _tmpList = new List <Param>();
            }
            else
            {
                _tmpList = new List <Param>(ParamsList);
            }

            getterFunc.ParamsList = _tmpList;

            getterFunc.ParamsList.Add(new ReturnParam()
            {
                Typs        = typs,
                Description = typDesc
            });

            // now add the datastructure into the current section of the current container
            if (!fileParser.CurrentSection.DataStructureDict.TryGetValue(getterFunc.GetName(), out List <DataStructure> dsList))
            {
                dsList = new List <DataStructure>();

                fileParser.CurrentSection.DataStructureDict.Add(getterFunc.GetName(), dsList);
            }

            dsList.Add(setterFunc);
            dsList.Add(getterFunc);
        }