public FunctionReplacer(CompoundFunction _func)
        {
            mCompound = _func;

            mReplace["MethodName"] = UpFirstLetter(mCompound.Name);
            mReplace["PropertyName"] = mCompound.PropertyName; // метод может быть заменен на свойство
            mReplace["OriginalMethodName"] = mCompound.Name;

            mReplace["OriginalTypeName"] = mCompound.CompoundType.TypeName;
            TypeInfo info = WrapperManager.Instance.GetTypeInfo(mCompound.CompoundType.TypeName);
            if (info != null)
            {
                foreach (var value in info.Values)
                    mReplace[value.First] = value.Second;
            }

            int index = 1;
            foreach (var type in mCompound.CompoundParamTypes)
            {
                mReplace["OriginalTypeName" + index.ToString()] = type.TypeName;
                if (type.ValueName != null)
                    mReplace["ValueName" + index.ToString()] = type.ValueName;
                else
                    mReplace["ValueName" + index.ToString()] = "_value" + index.ToString();

                TypeInfo parameInfo = WrapperManager.Instance.GetTypeInfo(type.TypeName);
                if (parameInfo != null)
                {
                    foreach (var value in parameInfo.Values)
                        mReplace[value.First + index.ToString()] = value.Second;
                }
                else
                {
                    //ConsoleUtility.WriteErrorLine("Type {0} not found", type.TypeName);
                }

                index++;
            }
        }
Beispiel #2
0
        private CompoundFunction PopSetterFunc(CompoundFunction _func, List<CompoundFunction> _funtions)
        {
            for (int index = 0; index < _funtions.Count; index++)
            {
                var func = _funtions[index];
                if (func.PropertyName == _func.PropertyName)
                {
                    if (func.CompoundType.TypeName == "void" &&
                        func.CompoundParamTypes.Count == 1 &&
                        (func.CompoundParamTypes[0].TypeName == _func.CompoundType.TypeName ||
                        func.CompoundParamTypes[0].PoorTypeName == _func.CompoundType.TypeName))
                    {
                        _funtions.RemoveAt(index);
                        return func;
                    }
                }
            }

            return null;
        }
Beispiel #3
0
 private bool GetAviableFunc(CompoundFunction _func)
 {
     if (_func.Internal)
         return false;
     if (!_func.Public)
         return false;
     if (_func.Static)
         return false;
     if (_func.Name.StartsWith("_"))
         return false;
     if (_func.Reimplement)
     {
         if (_func.Virtual)
             return false;
         if (_func.Generic)
             return false;
     }
     return true;
 }
Beispiel #4
0
 private string GetFunctionTemplateName(CompoundFunction _func)
 {
     bool returnType = _func.CompoundType.TypeName != "void";
     return string.Format("Method{0}{1}.txt", returnType ? "Return" : "", _func.CompoundParamTypes.Count);
 }
Beispiel #5
0
        private void AddClassFunction(CompoundFunction _func, TemplateInfo _info, ClassInfo _classInfo, FileData _outputFile)
        {
            string templateName = _classInfo.GetTeplaceTemplate(_func.Name);
            if (templateName == "")
                templateName = GetFunctionTemplateName(_func);

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