]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Laplace, run
authoralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Sep 2006 02:14:52 +0000 (02:14 +0000)
committeralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Sep 2006 02:14:52 +0000 (02:14 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1470 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/MigrationTools/org/tianocore/migration/Common.java
Tools/Source/MigrationTools/org/tianocore/migration/PathIterator.java
Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java

index fb89dcae4dfa452e65d43b2e05ade852a577caca..6b1208c7c6ad59ae7602b91a1d85b901616c781a 100644 (file)
@@ -155,19 +155,17 @@ public final class Common {
                File test;\r
 \r
                if (type == DIR || type == BOTH) {\r
-                       if (fda.dirFilter(path)) {\r
-                               fda.run(path);\r
-                       }\r
+                       fda.run(path);\r
                }\r
                for (int i = 0 ; i < list.length ; i++) {\r
                        test = new File(path + File.separator + list[i]);\r
                        if (test.isDirectory()) {\r
-                               toDoAll(path + File.separator + list[i], fda, type);\r
+                               if (fda.filter(test)) {\r
+                                       toDoAll(path + File.separator + list[i], fda, type);\r
+                               }\r
                        } else {\r
                                if (type == FILE || type == BOTH) {\r
-                                       if (fda.fileFilter(path + File.separator + list[i])) {\r
-                                               fda.run(path + File.separator + list[i]);\r
-                                       }\r
+                                       fda.run(path + File.separator + list[i]);\r
                                }\r
                        }\r
                }\r
@@ -176,8 +174,14 @@ public final class Common {
        public static interface ForDoAll {\r
                public void run(String filepath) throws Exception;\r
                \r
-               public boolean dirFilter(String filepath);\r
+               public boolean filter(File dir);\r
+       }\r
+       \r
+       public static abstract class Laplace {\r
+               public final void transform(String src, String des) throws Exception {\r
+                       Common.string2file(operation(Common.file2string(src)), des);\r
+               }\r
                \r
-               public boolean fileFilter(String filepath);\r
+               public abstract String operation(String wholeline);\r
        }\r
 }\r
index ffd11070672b124d8af64690cde405b4764a2c4e..40a9805cdbc949472f3dd6efdffa3f58c2f52f6f 100644 (file)
@@ -12,6 +12,7 @@
  **/\r
 package org.tianocore.migration;\r
 \r
+import java.io.File;\r
 import java.util.*;\r
 \r
 public final class PathIterator implements Common.ForDoAll {\r
@@ -31,6 +32,10 @@ public final class PathIterator implements Common.ForDoAll {
                pathlist.add(path);\r
        }\r
 \r
+       public boolean filter(File dir) {\r
+               return true;\r
+       }\r
+       \r
        public final String next() {\r
                return it.next();\r
        }\r
@@ -42,12 +47,4 @@ public final class PathIterator implements Common.ForDoAll {
        public final String toString() {\r
                return pathlist.toString();\r
        }\r
-       \r
-       public boolean dirFilter(String filepath) {\r
-               return true;\r
-       }\r
-       \r
-       public boolean fileFilter(String filepath) {\r
-               return true;\r
-       }\r
 }\r
index 67e5bc25677ee4fdd9067039a14e41f5aaad6d2c..361036251eaeb38e5ac4401c6156d4c0756a9a66 100644 (file)
@@ -20,7 +20,7 @@ import java.util.regex.Pattern;
 public final class SourceFileReplacer implements Common.ForDoAll {\r
        private static final SourceFileReplacer SFReplacer = new SourceFileReplacer();\r
        private ModuleInfo mi;\r
-       private static boolean showdetails = true;              // set this as default now, may be changed in the future\r
+       //private static boolean showdetails = true;            // set this as default now, may be changed in the future\r
        \r
        private static class r8tor9 {\r
                r8tor9(String r8, String r9) {\r
@@ -39,49 +39,6 @@ public final class SourceFileReplacer implements Common.ForDoAll {
        private static final Set<r8tor9> fileprotocol = new HashSet<r8tor9>();\r
        private static final Set<String> filer8only = new HashSet<String>();\r
        \r
-       private static final String addincludefile(String wholeline, String hfile) {\r
-               return wholeline.replaceFirst("(\\*/\\s)", "$1\n#include " + hfile + "\n");\r
-       }\r
-       \r
-       private final String convertdxs(String wholeline) {\r
-               if (mi.getModuleType().equals("PEIM")) {\r
-                       return addincludefile(wholeline, "\\<PeimDepex.h\\>");\r
-               } else {\r
-                       return addincludefile(wholeline, "\\<DxeDepex.h\\>");\r
-               }\r
-       }\r
-       \r
-       private final void addr8only() throws Exception {\r
-               String paragraph = null;\r
-               String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");\r
-               PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));\r
-               PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));\r
-               Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);\r
-               Matcher mtrr8only = ptnr8only.matcher(line);\r
-               Matcher mtrr8onlyhead;\r
-               while (mtrr8only.find()) {\r
-                       if (mi.hashr8only.contains(mtrr8only.group(2))) {\r
-                               paragraph = mtrr8only.group();\r
-                               outfile1.append(paragraph + "\n\n");\r
-                               if (mtrr8only.group(1).length() != 0) {\r
-                                       mi.hashrequiredr9libs.add(mtrr8only.group(1));\r
-                               }\r
-                               //generate R8lib.h\r
-                               while ((mtrr8onlyhead = Func.ptnbrace.matcher(paragraph)).find()) {\r
-                                       paragraph = mtrr8onlyhead.replaceAll(";");\r
-                               }\r
-                               outfile2.append(paragraph + "\n\n");\r
-                       }\r
-               }\r
-               outfile1.flush();\r
-               outfile1.close();\r
-               outfile2.flush();\r
-               outfile2.close();\r
-               \r
-               mi.localmodulesources.add("R8Lib.h");\r
-               mi.localmodulesources.add("R8Lib.c");\r
-       }\r
-       \r
        // Caution : if there is @ in file , it will be replaced with \n , so is you use Doxygen ... God Bless you!\r
        private final String sourcefilereplace(String wholeline) throws Exception {\r
                boolean addr8 = false;\r
@@ -233,22 +190,32 @@ public final class SourceFileReplacer implements Common.ForDoAll {
 \r
                return wholeline;\r
        }\r
+\r
+       private static final String addincludefile(String wholeline, String hfile) {\r
+               return wholeline.replaceFirst("(\\*/\\s)", "$1\n#include " + hfile + "\n");\r
+       }\r
        \r
+       private final String convertdxs(String wholeline) {\r
+               if (mi.getModuleType().equals("PEIM")) {\r
+                       return addincludefile(wholeline, "\\<PeimDepex.h\\>");\r
+               } else {\r
+                       return addincludefile(wholeline, "\\<DxeDepex.h\\>");\r
+               }\r
+       }\r
+\r
        private static final void show(Set<r8tor9> hash, String sh) {\r
                Iterator<r8tor9> it = hash.iterator();\r
                r8tor9 temp;\r
-               if (showdetails) {\r
-                       if (!hash.isEmpty()) {\r
-                               MigrationTool.ui.print("Converting " + sh + " : ");\r
-                               while (it.hasNext()) {\r
-                                       temp = it.next();\r
-                                       MigrationTool.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] ");\r
-                               }\r
-                               MigrationTool.ui.println("");\r
+               if (!hash.isEmpty()) {\r
+                       MigrationTool.ui.print("Converting " + sh + " : ");\r
+                       while (it.hasNext()) {\r
+                               temp = it.next();\r
+                               MigrationTool.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] ");\r
                        }\r
+                       MigrationTool.ui.println("");\r
                }\r
        }\r
-       \r
+\r
        private static final void replaceGuid(String line, Set<String> hash, String kind, Set<r8tor9> filehash) {\r
                Iterator<String> it;\r
                String r8thing;\r
@@ -266,6 +233,37 @@ public final class SourceFileReplacer implements Common.ForDoAll {
                        }\r
                }\r
        }\r
+\r
+       private final void addr8only() throws Exception {\r
+               String paragraph = null;\r
+               String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");\r
+               PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));\r
+               PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));\r
+               Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);\r
+               Matcher mtrr8only = ptnr8only.matcher(line);\r
+               Matcher mtrr8onlyhead;\r
+               while (mtrr8only.find()) {\r
+                       if (mi.hashr8only.contains(mtrr8only.group(2))) {\r
+                               paragraph = mtrr8only.group();\r
+                               outfile1.append(paragraph + "\n\n");\r
+                               if (mtrr8only.group(1).length() != 0) {\r
+                                       mi.hashrequiredr9libs.add(mtrr8only.group(1));\r
+                               }\r
+                               //generate R8lib.h\r
+                               while ((mtrr8onlyhead = Func.ptnbrace.matcher(paragraph)).find()) {\r
+                                       paragraph = mtrr8onlyhead.replaceAll(";");\r
+                               }\r
+                               outfile2.append(paragraph + "\n\n");\r
+                       }\r
+               }\r
+               outfile1.flush();\r
+               outfile1.close();\r
+               outfile2.flush();\r
+               outfile2.close();\r
+               \r
+               mi.localmodulesources.add("R8Lib.h");\r
+               mi.localmodulesources.add("R8Lib.c");\r
+       }\r
        \r
        //-----------------------------------ForDoAll-----------------------------------//\r
        public void run(String filepath) throws Exception {\r
@@ -297,11 +295,7 @@ public final class SourceFileReplacer implements Common.ForDoAll {
                }\r
        }\r
        \r
-       public boolean dirFilter(String filepath) {\r
-               return true;\r
-       }\r
-       \r
-       public boolean fileFilter(String filepath) {\r
+       public boolean filter(File dir) {\r
                return true;\r
        }\r
        //-----------------------------------ForDoAll-----------------------------------//\r