Exemplo n.º 1
0
        //============================================================
        // <T>解析*.h文件,查找相应的类的信息。</T>
        //
        // @param fileH 要解析的*.h文件
        // @param classStr 需要匹配的类的类名信息
        // @return 返回匹配到的类的结果。若是没有则返回null
        //============================================================
        public FCppClass ParserFileH(string fileH, string classStr)
        {
            FLineFile lineFileH = new FLineFile(fileH);
            FStrings  lines     = lineFileH;

            for (int n = 0; n < lines.Count; n++)
            {
                if (FCppClass.IsClass(lines, n))
                {
                    string strTemp = lines[n].Trim();
                    int    end     = strTemp.Length;
                    if (strTemp.Contains(':'))
                    {
                        end = strTemp.IndexOf(':');
                    }
                    strTemp = strTemp.Substring(0, end);
                    if (strTemp.Contains(classStr))
                    {
                        int       endIndex = GetPairNum(lines, n);
                        FCppClass cppclass = new FCppClass(lines, n, endIndex);
                        for (int i = n; i < endIndex; i++)
                        {
                            if (FCppField.IsField(lines, i))
                            {
                                FCppField field = new FCppField(lines, i);
                                cppclass.Field.Add(field);
                            }
                        }
                        return(cppclass);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        //============================================================
        // <T>扫描资源控制台。</T>
        //
        // @author TYFNG 20120409
        //============================================================
        public void Scan()
        {
            // 检查文件存在性
            if (!RDirectory.Exists(_directory))
            {
                return;
            }
            // 扫描文件
            FStrings fileNames = RDirectory.ListFiles(_directory);

            foreach (string fileName in fileNames)
            {
                // 检查后缀
                if (!fileName.EndsWith(".xml"))
                {
                    continue;
                }
                // 解析资源
                string     name    = fileName.Substring(fileName.LastIndexOf("\\") + 1);
                string     code    = name.Substring(0, name.Length - 4);
                FRsDataset dataset = new FRsDataset();
                dataset.Code     = code;
                dataset.FileName = fileName;
                _datasets.Set(code, dataset);
            }
        }
Exemplo n.º 3
0
        //============================================================
        // <T>扫描资源。</T>
        //============================================================
        public override void Scan()
        {
            base.Scan();
            // 扫描所有文件
            _optionValid = true;
            FStrings fileNames = RDirectory.ListFiles(_directory);

            fileNames.Sort();
            foreach (string fileName in fileNames)
            {
                // 文件是否图片
                string name = fileName.Substring(fileName.LastIndexOf("\\") + 1);
                if (name.EndsWith(".png"))
                {
                    name = name.Substring(0, name.Length - 4);
                    // 是否符合命名标准
                    if (5 == name.Length)
                    {
                        int direction  = RInt.Parse(name.Substring(0, 1));
                        int frameIndex = RInt.Parse(name.Substring(1)) - 1;
                        // 同步剪辑
                        FRsResourceClip  clip  = SyncClip(direction);
                        FRsResourceFrame frame = new FRsResourceFrame();
                        frame.FileName = fileName;
                        clip.PushFrame(frame);
                        // 设置有效
                        _optionValid = true;
                    }
                    else
                    {
                        RMoCore.TrackConsole.Write(this, "Scan", "Invalid picture define. (file_name={0})", fileName);
                    }
                }
            }
            // 检查剪辑帧数相等
            FRsResourceClip firstClip = FristClip;

            if (null != firstClip)
            {
                foreach (FRsResourceClip clip in _clips)
                {
                    if (clip != null)
                    {
                        if (firstClip.FrameCount != clip.FrameCount)
                        {
                            RMoCore.TrackConsole.Write(this, "Scan", "Animation clip frame is differenty. (first_frames={0}, clip_frames={1})",
                                                       firstClip.FrameCount, clip.FrameCount);
                        }
                    }
                }
            }
            string _configName = _directory + "\\config.xml";

            if (RFile.Exists(_configName))
            {
                FXmlDocument xdoc = new FXmlDocument();
                xdoc.LoadFile(_configName);
                LoadConfig(xdoc.Root);
            }
        }
Exemplo n.º 4
0
 //============================================================
 // <T>向对象传入相应的值。</T>
 //
 // @param strLine 需要传入的字符串行。也就是解析文件所得的各行
 // @param beginLine 属于该对象的行起始行索引
 // @param endLine 属于该对象的行终止索引
 //============================================================
 public void FillValue(FStrings strlines, int beginIndex, int endIndex)
 {
     _strLine    = strlines;
     _beginIndex = beginIndex;
     _endIndex   = endIndex;
     _methodStr  = strlines[beginIndex].ToString().Trim();
 }
Exemplo n.º 5
0
        //============================================================
        // <T>扫描工作路径,获得对象列表。</T>
        //============================================================
        public override void Scan()
        {
            base.Scan();
            // 检查文件集合
            FStrings fileNames = RDirectory.ListFiles(_directory);

            foreach (string fileName in fileNames)
            {
                if (fileName.EndsWith(".xml"))
                {
                    string name = RFile.GetFileName(fileName);
                    name = name.Substring(0, name.Length - 4);
                    if (name.StartsWith("import.") || name.StartsWith("temp."))
                    {
                        continue;
                    }
                    FDrScene scene = new FDrScene();
                    scene.Name            = _name;
                    scene.Label           = _label;
                    scene.TechniqueName   = name;
                    scene.Directory       = _directory;
                    scene.DirectoryExprot = _directoryExprot;
                    scene.Scan();
                    _scenes.Push(scene);
                }
            }
            // 设置目录
            _exportFileName = _directoryExprot + "\\sc_" + Code + ".swf";
            // 加载设置文件
            if (RFile.Exists(_configFileName))
            {
                //LoadConfig(new FXmlDocument(_directory + "\\config.xml").Root);
            }
        }
Exemplo n.º 6
0
        //============================================================
        // <T>获取段落注释的结束行的行号。</T>
        //
        // @param strLines 需要判断的字符串数组
        // @param index 需要开始判断的行号
        // @return 段落注释的结束行号
        //============================================================
        public int GetParaAnnotate(FStrings strLines, int index)
        {
            int end = index;
            int startAnno = 0, endAnno = 0;

            for (int n = 0; n < strLines.Count; n++)
            {
                if (IsParaAnnotateStart(strLines[n]))
                {
                    startAnno = 1;
                    end       = n;
                }
                if (IsParaAnnotateEnd(strLines[n]))
                {
                    endAnno = 1;
                    end     = n;
                }
                if ((startAnno == endAnno) && (startAnno == 1))
                {
                    return(n);
                }
                end = n;
            }
            return(end);
        }
Exemplo n.º 7
0
        //============================================================
        // <T>加载文件夹信息,取得地址。</T>
        // <P>加载文件下文件信息,取得文件地址。</P>
        //
        // @param directory 文件路径。
        //============================================================
        public void LoadDirectory(string directory)
        {
            // 加载给定路径下面的文件夹.
            FStrings paths = RDirectory.ListDirectories(directory);
            int      count = paths.Count;

            for (int n = 0; n < count; n++)
            {
                // 检查文件夹
                string path = paths[n];
                if (path.Contains(".svn"))
                {
                    continue;
                }
                // 取得文件夹类型名称。
                string name  = path.Substring(path.LastIndexOf("\\") + 1);
                string id    = name.Substring(0, name.IndexOf('-'));
                string label = name.Substring(name.IndexOf('-') + 1).Trim();
                // 文件夹的全路径地址。
                FDsMap map = new FDsMap();
                map.Resource.Directory = path;
                map.Resource.Tid       = RInt.Parse(id);
                map.Resource.Name      = name;
                map.Resource.Label     = label;
                map.Resource.LoadDirectory();
                _maps.Push(map.Resource);
            }
        }
Exemplo n.º 8
0
 //============================================================
 // <T>构造方法</T>
 //============================================================
 public FCsMethod()
 {
     _methodName = string.Empty;
     _methodType = string.Empty;
     _annotates  = new FStrings();
     _parameter  = new FArray <FCsParameter>();
 }
Exemplo n.º 9
0
 //============================================================
 // <T>构造函数</T>
 //============================================================
 public FCsClass()
 {
     _accessLevel = string.Empty;
     _className   = string.Empty;
     _annotates   = new FStrings();
     _method      = new FArray <FCsMethod>();
 }
Exemplo n.º 10
0
        //============================================================
        // <T>加载按钮事件。</T>
        //
        // @param sender 事件产生者
        // @param e      数据对象
        //============================================================
        private void tsbReload_Click(object sender, EventArgs e)
        {
            FStrings directorys = RDirectory.ListFiles(_resource.Directory);

            foreach (string fileName in directorys)
            {
                bool haveIt = false;
                if (fileName.EndsWith(".png"))
                {
                    //foreach (FDsResourceClip clip in _resourceAnimation.Clips) {
                    //   if (haveIt) {
                    //      break;
                    //   }
                    //   if (null != clip) {
                    //      foreach (FDsResourceFrame frame in clip.Frames) {
                    //         if (fileName.EndsWith(frame.FileName)) {
                    //            haveIt = true;
                    //            break;
                    //         }
                    //      }
                    //   }
                    //}
                    if (!haveIt)
                    {
                        MessageBox.Show(fileName);
                    }
                }
            }
        }
Exemplo n.º 11
0
 //============================================================
 // <T>获得文件夹下文件列表。</T>
 //
 // @param paths 文件列表
 // @param directory 文件夹
 // @param deep 深度
 //============================================================
 private static bool InnerListFiles(FStrings paths, string directory, bool deep, string extension, bool constainsDir, bool constainsFile)
 {
     if (!Directory.Exists(directory))
     {
         return(false);
     }
     // 搜索子文件夹
     foreach (string dir in Directory.GetDirectories(directory))
     {
         if (constainsDir)
         {
             paths.Push(dir);
         }
         if (deep)
         {
             InnerListFiles(paths, dir, deep, extension, constainsDir, constainsFile);
         }
     }
     // 搜索文件列表
     if (constainsFile)
     {
         foreach (string file in Directory.GetFiles(directory))
         {
             if (null == extension)
             {
                 paths.Push(file);
             }
             else if (file.EndsWith(extension))
             {
                 paths.Push(file);
             }
         }
     }
     return(true);
 }
Exemplo n.º 12
0
        //============================================================
        // <T>解析类对象的注释信息。</T>
        //============================================================
        public void ParserClassAnnotate()
        {
            FStrings description = new FStrings();

            for (int n = 0; n < Annotates.Count; n++)
            {
                string strtemp = Annotates[n].ToString().Trim();
                if (strtemp.Contains("</T>"))
                {
                    strtemp = strtemp.Replace("</T>", "");
                    if (strtemp.Contains("<T>"))
                    {
                        strtemp = strtemp.Substring(strtemp.IndexOf("<T>") + 3).Trim();
                    }
                    Label = strtemp.Trim();
                }
                if (strtemp.Contains("</P>"))
                {
                    strtemp = strtemp.Replace("</P>", "");
                    if (strtemp.Contains("<P>"))
                    {
                        strtemp = strtemp.Substring(strtemp.IndexOf("<P>") + 3).Trim();
                    }
                    description.Add(strtemp);
                }
            }
            if (description != null && description.Count > 0)
            {
                for (int n = 0; n < description.Count; n++)
                {
                    Description += description[n].ToString().Trim();
                }
            }
        }
Exemplo n.º 13
0
        //============================================================
        // <T>解析单个文件。</T>
        //
        // @param file 要解析的文件
        //============================================================
        public void ParserSingleFile(FileInfo file)
        {
            FStrings strLines = FCsParser.GetLines(new FFileInfo(file.FullName));

            for (int n = 0; n < strLines.Count; n++)
            {
                if (FCsParser.IsSpace(strLines[n].ToString()))
                {
                    string space = string.Empty;
                    int    endindex = FCsSpace.ParserSpace(strLines, n, out space);
                    int    start, end = CheckParaAnnotate(strLines, n, out start);
                    for (int i = n; i < endindex; i++)
                    {
                        if (IsInInterregional(i, start, end))
                        {
                            continue;
                        }
                        if (FCsSpace.IsClass(strLines[i].ToString()))
                        {
                            string   classStr = FCsClass.ParserClass(strLines, i);
                            FMapNode node     = new FMapNode(classStr, space);
                            AddNode(node);
                            n = i;
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        //============================================================
        // <T>目标文件内的代码字符串以行来划分。</T>
        //
        // @param fi 需要划分的代码串
        // @return 划分后的字符串集合
        //============================================================
        public static FStrings GetLines(FFileInfo fi)
        {
            FStrings lines = new FStrings();

            lines.Append(File.ReadAllLines(fi.DirectoryName + "\\" + fi.Name, System.Text.Encoding.UTF8));
            return(lines);
        }
Exemplo n.º 15
0
        //============================================================
        // <T>解析单个文件</T>
        //
        // @param file 要解析的文件
        //============================================================
        public void ParserSingleFile(FileInfo file)
        {
            FStrings strLines = FAsParser.GetLines(file.FullName);

            for (int n = 0; n < strLines.Count; n++)
            {
                if (FAsPackage.IsPackage(strLines, n))
                {
                    string package = string.Empty;
                    int    endindex = FAsPackage.ParserPackage(strLines, n, out package);
                    int    start, end = CheckParaAnnotate(strLines, n, out start);
                    for (int i = n; i < endindex; i++)
                    {
                        if (IsInInterregional(i, start, end))
                        {
                            continue;
                        }
                        if (FAsClass.IsClass(strLines, i))
                        {
                            string   classStr = FAsClass.ParserClass(strLines, i);
                            FMapNode node     = new FMapNode(classStr, package);
                            AddNode(node);
                            n = i;
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
 //============================================================
 // <T>构造方法,有参数的构造。</T>
 //
 // @param strLines 解析的代码行集合
 // @param begin 开始行索引
 // @param end 结束行索引
 //============================================================
 public FAsClass(FStrings strLines, int begin, int end)
 {
     this._strLine    = strLines;
     this._startIndex = begin;
     this._endIndex   = end;
     _annotates       = GetAnnotate(_strLine, _startIndex);
 }
Exemplo n.º 17
0
        //============================================================
        // <T>列出文件夹下所有子文件夹。</T>
        //
        // @param directory 文件夹
        // @param deep 深度
        //============================================================
        public static FStrings ListDirectories(string directory, bool deep = false)
        {
            FStrings directories = new FStrings();

            InnerListFiles(directories, directory, deep, null, true, false);
            directories.Sort();
            return(directories);
        }
Exemplo n.º 18
0
 //============================================================
 // <T>构造方法。</T>
 //
 // @param strLines 解析的代码行集合
 // @param beginIndex 开始行索引
 // @param endIndex 结束行索引
 //============================================================
 public FAsMethod(FStrings strlines, int beginIndex, int endIndex)
 {
     _methodName = string.Empty;
     _methodType = string.Empty;
     _beginIndex = beginIndex;
     _endIndex   = endIndex;
     _strLine    = strlines;
 }
Exemplo n.º 19
0
 //============================================================
 // <T>构造方法,带参数的构造</T>
 // @param strLine 所属于参数对象的的字符串组
 // @param annotate 所属于参数对象的注释字符串组
 // @param index 字符串组中参数所在行
 //============================================================
 public FAsParameter(string strParam, FStrings strLines, int index)
 {
     _parameterName = string.Empty;
     _parameterType = string.Empty;
     _index         = index;
     _parameterStr  = strParam;
     _strLines      = strLines;
 }
Exemplo n.º 20
0
 //============================================================
 // <T>构造函数</T>
 //============================================================
 public FCsSpace(FStrings strLine, int beginLine, int endLine)
 {
     _spaceStr   = strLine;
     _startIndex = beginLine;
     _endIndex   = endLine;
     _spaceName  = string.Empty;
     _class      = new FArray <FCsClass> ( );
 }
Exemplo n.º 21
0
 //============================================================
 // <T>构造方法,带参数的构造</T>
 // @param strLine 所属于参数对象的的字符串组
 // @param annotate 所属于参数对象的注释字符串组
 // @param index 字符串组中参数所在行
 //============================================================
 public FCsParameter(FStrings strLine, FStrings annotate, int index)
 {
     _parameterName = string.Empty;
     _parameterType = string.Empty;
     _strLine       = strLine;
     _annotateStr   = annotate;
     _index         = index;
 }
Exemplo n.º 22
0
        //============================================================
        // <T>列出文件夹下所有文件。</T>
        //
        // @param directory 文件夹
        // @param deep 深度
        //============================================================
        public static FStrings ListFiles(string directory, bool deep = false, string extension = null)
        {
            FStrings files = new FStrings();

            InnerListFiles(files, directory, deep, extension, false, true);
            files.Sort();
            return(files);
        }
Exemplo n.º 23
0
        //============================================================
        // <T>构造方法,有参数的构造。</T>
        //
        // @param index 属性对象的开始索引号
        // @param strLines 解析的代码行集合
        //============================================================
        public static bool IsProperty(FStrings strLines, int index)
        {
            string s = strLines[index].ToString().Trim();

            if (!s.Contains(" function "))
            {
                return(false);
            }
            if (!s.Contains('('))
            {
                return(false);
            }
            if (!s.Contains(')'))
            {
                return(false);
            }
            if (!s.Contains(" get ") && !s.Contains(" set "))
            {
                return(false);
            }
            if (s.Contains(" get "))
            {
                int b = s.IndexOf(" get ") + 6;
                int e = s.IndexOf('(');
                if (s.Substring(b, e - b).Trim() == "")
                {
                    return(false);
                }
            }
            if (s.Contains(" set "))
            {
                int b = s.IndexOf(" set ") + 6;
                int e = s.IndexOf('(');
                if (s.Substring(b, e - b).Trim() == "")
                {
                    return(false);
                }
            }
            int    indexChar = strLines[index].Trim().IndexOf(" ");
            string accessClassification;

            if (indexChar >= 0)
            {
                accessClassification = s.Substring(0, indexChar);
                FStrings accessClass = new FStrings()
                {
                    "public", "protected", "private", "partial", "internal"
                };
                foreach (string str in accessClass)
                {
                    if ((accessClassification == str) && !s.Contains('='))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 24
0
        //============================================================
        // <T>向对象传入相应的值。</T>
        // @param strLine 需要传入的字符串行。也就是解析文件所得的各行
        // @param beginLine 属于该对象的行起始行索引
        // @param endLine 属于该对象的行终止索引
        //============================================================
        public void FillValue(FStrings strLine, int startIndex, int endIndex)
        {
            _strLine    = strLine;
            _startIndex = startIndex;
            _endIndex   = endIndex;
            FStrings strs = GetAnnotate(_strLine, _startIndex);

            Annotates = strs;
        }
Exemplo n.º 25
0
 //============================================================
 // <T>构造方法</T>
 //============================================================
 public FAsProperty(FStrings strlines, int beginIndex, int endIndex)
 {
     _propertyName = string.Empty;
     _propertyType = string.Empty;
     _annotates    = new FStrings();
     _strLine      = strlines;
     _beginIndex   = beginIndex;
     _endIndex     = endIndex;
 }
Exemplo n.º 26
0
        //============================================================
        // <T>获取命名空间和结束行索引。</T>
        // @parame strlines 需要获取的字符串集合。
        // @param index 当前索引
        // @param out string 获取的命名空间对象
        // @return 命名空间的结束行索引
        //============================================================
        public static int ParserSpace(FStrings strLines, int index, out string spaceString)
        {
            FCsSpace space   = new FCsSpace();
            int      end     = space.GetPairNum(strLines, index);
            string   strTemp = strLines[index].ToString().Trim();

            spaceString = space.GetSpaceName(strTemp);
            return(end);
        }
Exemplo n.º 27
0
 //============================================================
 // <T>构造方法</T>
 //============================================================
 public FCsMethod(FStrings strlines, int beginIndex, int endIndex)
 {
     _methodName = string.Empty;
     _methodType = string.Empty;
     _annotates  = new FStrings();
     _parameter  = new FArray <FCsParameter>();
     _strLine    = strlines;
     _beginIndex = beginIndex;
     _endIndex   = endIndex;
 }
Exemplo n.º 28
0
 //============================================================
 // <T>构造函数</T>
 //============================================================R
 public FCsClass(FStrings strLine, int startIndex, int endIndex)
 {
     _accessLevel = string.Empty;
     _className   = string.Empty;
     _annotates   = new FStrings();
     _method      = new FArray <FCsMethod>();
     _strLine     = strLine;
     _startIndex  = startIndex;
     _endIndex    = endIndex;
 }
Exemplo n.º 29
0
        //============================================================
        // <T>判断是否为Class对象。</T>
        //
        // @param strLines 正在判断的所在字符串集合
        // @param index 正在判断的当前行
        //============================================================
        public static bool IsClass(FStrings strLines, int index)
        {
            string str = strLines[index].Trim();

            if (str.StartsWith("class ") && !str.Contains(";"))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 30
0
        //============================================================
        // <T>解析H文件中的模板类。</T>
        //============================================================
        public void ParserTemplate(string filePath)
        {
            FStrings strLines = FCppParser.GetLines(filePath);

            for (int n = 0; n < strLines.Count; n++)
            {
                if (FCppClass.IsTemplateClass(strLines, n))
                {
                }
            }
        }