Beispiel #1
0
        private void AddClassData(Compound _compound, TemplateInfo _info, ClassInfo _classInfo, FileData _outputFile)
        {
            List<CompoundFunction> funtions = new List<CompoundFunction>();
            List<Pair<CompoundFunction, CompoundFunction>> properties = new List<Pair<CompoundFunction, CompoundFunction>>();
            List<CompoundVariable> variables = new List<CompoundVariable>();

            foreach (Compound child in _compound)
            {
                if (child is CompoundFunction)
                {
                    CompoundFunction func = (CompoundFunction)child;
                    if (GetAviableFunc(func))
                    {
                        if (
                            //func.Const &&
                            func.CompoundParamTypes.Count == 0 &&
                            func.CompoundType.TypeName != "void" &&
                            (func.GetProperty || func.IsProperty))
                            properties.Add(new Pair<CompoundFunction, CompoundFunction>(func, null));
                        else
                            funtions.Add(func);
                    }
                }
                else if (child is CompoundVariable)
                {
                    CompoundVariable variable = (CompoundVariable)child;
                    if (variable.Public &&
                        !variable.Static &&
                        !variable.Name.StartsWith("_") &&
                        CompoundUtility.IsVariableEvent(variable))
                    {
                        variables.Add(variable);
                    }
                }
            }

            // вытаскиваем сетеры для свойств из списка функций
            foreach (var func in properties)
                func.Second = PopSetterFunc(func.First, funtions);

            foreach (var func in properties)
                AddClassProperty(func, _info, _classInfo, _outputFile);

            foreach (var func in funtions)
                AddClassFunction(func, _info, _classInfo, _outputFile);

            foreach (var variable in variables)
                AddClassEvent(variable, _info, _classInfo, _outputFile);
        }
Beispiel #2
0
        private void DoWrappTemplate(TemplateInfo _info, ClassInfo _classInfo, Compound _compound)
        {
            FileData outputFile = mOutputManager.GetOutputFile(_info.Output);

            if (outputFile.Data.Length == 0)
            {
                FileData template = mTemplateManager.GetTemplateCopy(GetTemplateFileName(_info.TemplateFolder, _info.OutputTemplate));
                mReplaceManager.DoReplace(template, new IReplacer[] { _classInfo });
                AppendData(outputFile, template);
            }

            if (_info.Template != "")
            {
                FileData template = mTemplateManager.GetTemplateCopy(GetTemplateFileName(_info.TemplateFolder, _info.Template));
                mReplaceManager.DoReplace(template, new IReplacer[] { _classInfo });
                InsertData(outputFile, template, mLabelName);
            }
            else
            {
                AddClassData(_compound, _info, _classInfo, outputFile);
            }
        }
Beispiel #3
0
        private void AddClassProperty(Pair<CompoundFunction, CompoundFunction> _func, TemplateInfo _info, ClassInfo _classInfo, FileData _outputFile)
        {
            string templateName = _classInfo.GetTeplaceTemplate(_func.First.Name);
            if (templateName == "")
                templateName = GetPropertyTemplateName(_func);

            FileData template = mTemplateManager.GetTemplateCopy(GetTemplateFileName(_info.TemplateFolder, templateName));
            mReplaceManager.DoReplace(template, new IReplacer[] { _classInfo, new PropertyReplacer(_func) });
            InsertData(_outputFile, template, mLabelName);
        }
Beispiel #4
0
        private void DoWrappClass(ClassInfo _info)
        {
            ConsoleUtility.WriteLine("Wrapp {0}", _info.Type);

            Compound compound = CompoundManager.Instance.GetCompoundByName(_info.Type);
            foreach (TemplateInfo info in _info.Templates)
                DoWrappTemplate(info, _info, compound);
        }
Beispiel #5
0
        private void AddClassEvent(CompoundVariable _variable, TemplateInfo _info, ClassInfo _classInfo, FileData _outputFile)
        {
            string templateName = _classInfo.GetTeplaceTemplate(_variable.Name);
            if (templateName == "")
                templateName = GetEventTemplateName(_variable);

            FileData template = mTemplateManager.GetTemplateCopy(GetTemplateFileName(_info.TemplateFolder, templateName));
            mReplaceManager.DoReplace(template, new IReplacer[] { _classInfo, new EventReplacer(_variable) });
            InsertData(_outputFile, template, mLabelName);
        }