]> git.proxmox.com Git - mirror_edk2.git/commitdiff
let critic prepared
authoralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 4 Sep 2006 08:43:05 +0000 (08:43 +0000)
committeralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 4 Sep 2006 08:43:05 +0000 (08:43 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1439 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/MigrationTools/org/tianocore/migration/Critic.java
Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java
Tools/Source/MigrationTools/org/tianocore/migration/MsaWriter.java
Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java

index fb966103a07d8ece9ba9fe59e298e11988e0eae8..b9f62423526d9f10b91db93024b0041d6254f355 100644 (file)
@@ -26,7 +26,13 @@ public final class Critic {
        \r
        private static final int totallinelength = 82;\r
        \r
        \r
        private static final int totallinelength = 82;\r
        \r
-       public static final void critic(String filepath) throws Exception {\r
+       public static final void run(String filepath) throws Exception {\r
+               if (MigrationTool.doCritic) {\r
+                       critic(filepath);\r
+               }\r
+       }\r
+       \r
+       private static final void critic(String filepath) throws Exception {\r
                if (filepath.contains(".c") || filepath.contains(".h")) {\r
                        BufferedReader rd = null;\r
                        String line = null;\r
                if (filepath.contains(".c") || filepath.contains(".h")) {\r
                        BufferedReader rd = null;\r
                        String line = null;\r
@@ -180,66 +186,15 @@ public final class Critic {
                        }\r
                        wholeline = templine.toString();\r
                        //\r
                        }\r
                        wholeline = templine.toString();\r
                        //\r
-                       \r
-                       /* -----slow edition of replacefirst with stringbuffer-----\r
-                       line.append(wholeline);\r
-                       mtrfunccomment = ptnfunccomment.matcher(line);\r
-                       while (mtrfunccomment.find()) {\r
-                               line.replace(0, line.length()-1, mtrfunccomment.replaceFirst("$2$4$3$1$5"));\r
-                       }\r
-                       */\r
-                       /* -----slow edition of replacefirst with string-----\r
-                       while ((mtrfunccomment = ptnfunccomment.matcher(wholeline)).find()) {\r
-                               //funccomment = mtrfunccomment.group(2);\r
-                               //mtrcommentstructure = ptncommentstructure.matcher(funccomment);\r
-                               wholeline = mtrfunccomment.replaceFirst("$2$4$3$1$5");\r
-                       }\r
-                       */\r
-                       /*\r
-                       // edit func comment\r
-                       mtrtempcomment = ptntempcomment.matcher(wholeline);\r
-                       while (mtrtempcomment.find()) {\r
-                               System.out.println("-----------------------------");\r
-                               System.out.println(mtrtempcomment.group());\r
-                               System.out.println("-----------------------------");\r
-                       }\r
-                       */\r
+\r
                        Common.string2file(wholeline, filepath);\r
                }\r
        }\r
        \r
        public static final void fireAt(String path) throws Exception {\r
                //Common.toDoAll(Common.dirCopy_(path), Critic.class.getMethod("critic", String.class), null, null, Common.FILE);\r
                        Common.string2file(wholeline, filepath);\r
                }\r
        }\r
        \r
        public static final void fireAt(String path) throws Exception {\r
                //Common.toDoAll(Common.dirCopy_(path), Critic.class.getMethod("critic", String.class), null, null, Common.FILE);\r
-               Common.toDoAll(path, Critic.class.getMethod("critic", String.class), null, null, Common.FILE);\r
+               Common.toDoAll(path, Critic.class.getMethod("run", String.class), null, null, Common.FILE);\r
                //Common.toDoAll(Common.dirCopy_(path), critic, Common.FILE);\r
                System.out.println("Critic Done");\r
        }\r
                //Common.toDoAll(Common.dirCopy_(path), critic, Common.FILE);\r
                System.out.println("Critic Done");\r
        }\r
-}\r
-//analyze func comment\r
-/*if (mtrcommentstructure.find()) {\r
-       newcomment.append("/*++\n\n" + mtrcommentstructure.group(1) + "\n\n");\r
-       \r
-       //System.out.println("-------1-------");\r
-       //System.out.println(mtrcommentstructure.group(1));\r
-       \r
-       // arg\r
-       //System.out.println("-------2-------");\r
-       //System.out.println(mtrcommentstructure.group(2));\r
-       mtrinfequation = ptninfequation.matcher(mtrcommentstructure.group(2));\r
-       while (mtrinfequation.find()) {\r
-               newcomment.append("@param   " + mtrinfequation.group(1) + "            " + mtrinfequation.group(2) + "\n");\r
-               //System.out.println("@param   " + mtrinfequation.group(1) + "   " + mtrinfequation.group(2));\r
-       }\r
-       newcomment.append("\n");\r
-       // return\r
-       //System.out.println("-------3-------");\r
-       //System.out.println(mtrcommentstructure.group(3));\r
-       mtrinfequation = ptninfequation.matcher(mtrcommentstructure.group(3));\r
-       while (mtrinfequation.find()) {\r
-               newcomment.append("@retval   " + mtrinfequation.group(1) + "            " + mtrinfequation.group(2) + "\n");\r
-               //System.out.println("@retval   " + mtrinfequation.group(1) + "   " + mtrinfequation.group(2));\r
-       }\r
-       System.out.println(newcomment);\r
-} else {\r
-       System.out.println("Error: Comment Style Incorrect");\r
-}*/
\ No newline at end of file
+}
\ No newline at end of file
index 90274d0910b68f5ec0fcf453098a3b8a01313f60..e99a76edf421e44985af6b11cea5458c17158a38 100644 (file)
@@ -204,6 +204,7 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
         if ( e.getSource() == specifyCommentButton) {\r
                try {                                                                                   // input examine is not imposed but should be added\r
                        MigrationTool.MIGRATIONCOMMENT = getInput("Please type in wanted comment style used by the tool\nbe sure to start with '//', or you won't enjoy the result");\r
         if ( e.getSource() == specifyCommentButton) {\r
                try {                                                                                   // input examine is not imposed but should be added\r
                        MigrationTool.MIGRATIONCOMMENT = getInput("Please type in wanted comment style used by the tool\nbe sure to start with '//', or you won't enjoy the result");\r
+                       //MsaWriter.parse("C:\\tianocore\\edk2\\MdePkg\\Library\\BaseLib\\BaseLib.msa");\r
                } catch (Exception en) {\r
                        println(en.getMessage());\r
                }\r
                } catch (Exception en) {\r
                        println(en.getMessage());\r
                }\r
index d6d836cc740eaf32f0c71d30179512fbd393314f..aeed32d345673e84cf8ebdc1d87b05ba37dd54ae 100644 (file)
@@ -187,4 +187,23 @@ public class MsaWriter {
                bw.flush();\r
                bw.close();\r
        }\r
                bw.flush();\r
                bw.close();\r
        }\r
+\r
+       private static void flush(String path, ModuleSurfaceAreaDocument msadoc) throws Exception {\r
+        XmlOptions options = new XmlOptions();\r
+\r
+        options.setCharacterEncoding("UTF-8");\r
+        options.setSavePrettyPrint();\r
+        options.setSavePrettyPrintIndent(2);\r
+        options.setUseDefaultNamespace();\r
+\r
+               BufferedWriter bw = new BufferedWriter(new FileWriter(path));\r
+               msadoc.save(bw, options);\r
+               bw.flush();\r
+               bw.close();\r
+       }\r
+       \r
+       public static final void parse(String msafile) throws Exception {\r
+               ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.parse(msafile);\r
+               flush("c:\\temp.msa", msadoc);\r
+       }\r
 }\r
 }\r
index 8ae1d8d05e0283360db2f8352d521e0576371a87..a12be4a9a876308354d594fc255c25f3fdfd57d1 100644 (file)
@@ -44,11 +44,7 @@ public final class SourceFileReplacer {
                \r
                String outname = null;\r
                String inname = null;\r
                \r
                String outname = null;\r
                String inname = null;\r
-               /*\r
-               if (MigrationTool.ui.yesOrNo("Changes will be made to the Source Code.  View details?")) {\r
-                       showdetails = true;\r
-               }\r
-               */\r
+\r
                showdetails = true;                     // set this as default now, may be changed in the future\r
                \r
                Iterator<String> di = mi.localmodulesources.iterator();\r
                showdetails = true;                     // set this as default now, may be changed in the future\r
                \r
                Iterator<String> di = mi.localmodulesources.iterator();\r
@@ -81,7 +77,6 @@ public final class SourceFileReplacer {
        private static final void addr8only() throws Exception {\r
                String paragraph = null;\r
                String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");\r
        private static final void addr8only() throws Exception {\r
                String paragraph = null;\r
                String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");\r
-               //Common.ensureDir(mi.modulepath + File.separator + "Migration_" + mi.modulename + 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
                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
@@ -115,9 +110,6 @@ public final class SourceFileReplacer {
                BufferedReader rd = new BufferedReader(new FileReader(filename));\r
                StringBuffer wholefile = new StringBuffer();\r
                String line;\r
                BufferedReader rd = new BufferedReader(new FileReader(filename));\r
                StringBuffer wholefile = new StringBuffer();\r
                String line;\r
-               String r8thing;\r
-               String r9thing;\r
-               r8tor9 temp;\r
                boolean addr8 = false;\r
 \r
                Pattern pat = Pattern.compile("g?(BS|RT)(\\s*->\\s*)([a-zA-Z_]\\w*)", Pattern.MULTILINE);                                       // ! only two level () bracket allowed !\r
                boolean addr8 = false;\r
 \r
                Pattern pat = Pattern.compile("g?(BS|RT)(\\s*->\\s*)([a-zA-Z_]\\w*)", Pattern.MULTILINE);                                       // ! only two level () bracket allowed !\r
@@ -153,6 +145,8 @@ public final class SourceFileReplacer {
                }\r
                */\r
                // start replacing names\r
                }\r
                */\r
                // start replacing names\r
+               String r8thing;\r
+               String r9thing;\r
                Iterator<String> it;\r
                // Converting non-locla function\r
                it = mi.hashnonlocalfunc.iterator();\r
                Iterator<String> it;\r
                // Converting non-locla function\r
                it = mi.hashnonlocalfunc.iterator();\r
@@ -168,7 +162,8 @@ public final class SourceFileReplacer {
                        } else {                                                                                                                        //\r
                                mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing));                          // add a library here\r
                        }\r
                        } else {                                                                                                                        //\r
                                mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing));                          // add a library here\r
                        }\r
-                       \r
+\r
+                       r8tor9 temp;\r
                        if ((r9thing = MigrationTool.db.getR9Func(r8thing)) != null) {\r
                                if (!r8thing.equals(r9thing)) {\r
                                        if (line.contains(r8thing)) {\r
                        if ((r9thing = MigrationTool.db.getR9Func(r8thing)) != null) {\r
                                if (!r8thing.equals(r9thing)) {\r
                                        if (line.contains(r8thing)) {\r