Fix several bugs & enhancement.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 12 Oct 2006 10:31:02 +0000 (10:31 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 12 Oct 2006 10:31:02 +0000 (10:31 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1731 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/MigrationTools/org/tianocore/migration/Macro.java
Tools/Java/Source/MigrationTools/org/tianocore/migration/ModuleReader.java
Tools/Java/Source/MigrationTools/org/tianocore/migration/MsaWriter.java
Tools/Java/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java

index bd10b5a..57c85d9 100644 (file)
@@ -27,7 +27,7 @@ public class Macro {
     public String r8name;\r
     public String r9name;\r
 \r
-    public static Pattern ptntmacro = Pattern.compile("\\b[A-Z_]+\\s*?\\(?\\b",Pattern.MULTILINE);\r
+    public static Pattern ptntmacro = Pattern.compile("\\b\\w(\\w|\\d)*",Pattern.MULTILINE);\r
 \r
     private static String unmacro = "VOID UINTN BOOLEAN ASSERT OPTIONAL STATIC NULL TRUE IN OUT FALSE";\r
 \r
index 7880f2b..09d4262 100644 (file)
@@ -185,7 +185,7 @@ public final class ModuleReader implements Common.ForDoAll {
         Iterator<String> ii = mi.localmodulesources.iterator();\r
         while (ii.hasNext()) {\r
             temp = ii.next();\r
-            if (temp.contains(".c")) {\r
+            if (temp.contains(".c") || temp.contains(".dxs")) {\r
                 mi.preprocessedccodes.add(temp);\r
             }\r
         }\r
index 3db2507..132d6c3 100644 (file)
@@ -70,11 +70,20 @@ public class MsaWriter {
             filename.setSupArchList(arch);\r
         }\r
     }\r
-    \r
+    private void addWrapper() {\r
+        XmlCursor cursor = msa.newCursor();\r
+        String uri = "http://www.TianoCore.org/2006/Edk2.0";\r
+        cursor.push();\r
+        cursor.toNextToken();\r
+        cursor.insertNamespace("", uri);\r
+        cursor.insertNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");\r
+        cursor.pop();\r
+        msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)cursor.getObject();\r
+    }\r
     private ModuleSurfaceAreaDocument fulfillMsadoc() throws Exception {\r
         Iterator<String> it;\r
         String temp;\r
-        \r
+       \r
         if (mi.modulename != null) {\r
             msaheader.setModuleName(mi.modulename);\r
         } else {\r
@@ -173,7 +182,8 @@ public class MsaWriter {
                 lc.setUsage(UsageTypes.ALWAYS_CONSUMED);\r
             }\r
         }\r
-        \r
+        addWrapper();\r
+        msadoc.setModuleSurfaceArea(msa);\r
         return msadoc;\r
     }\r
     \r
@@ -184,7 +194,7 @@ public class MsaWriter {
         options.setSavePrettyPrint();\r
         options.setSavePrettyPrintIndent(2);\r
         options.setUseDefaultNamespace();\r
-        \r
+\r
         BufferedWriter bw = new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".msa"));\r
         fulfillMsadoc().save(bw, options);\r
         //MsaTreeEditor.init(mi, ui, msadoc);\r
index 01678a3..e37f7f4 100644 (file)
@@ -86,6 +86,7 @@ public final class SourceFileReplacer implements Common.ForDoAll {
     }\r
     private class DxsLaplace extends Common.Laplace {\r
         public String operation(String wholeline) {\r
+            wholeline = replaceMacro(wholeline, mi.hashnonlocalmacro);\r
             if (mi.getModuleType().equals("PEIM")) {\r
                 return addincludefile(wholeline, "\\<PeimDepex.h\\>");\r
             } else {\r
@@ -105,7 +106,7 @@ public final class SourceFileReplacer implements Common.ForDoAll {
     private class CLaplace extends Common.Laplace {\r
         public  String operation(String wholeline) {\r
             // remove EFI_DRIVER_ENTRY_POINT\r
-            wholeline = wholeline.replaceAll("(EFI_[A-Z]+_ENTRY_POINT\\s*\\(\\s*" + mi.entrypoint + "\\s*\\)\\s*;)", MigrationTool.MIGRATIONCOMMENT + " $1");\r
+            wholeline = wholeline.replaceAll("(EFI_[A-Z]+_ENTRY_POINT\\s*\\(\\s*\\w(\\w|\\d)*\\s*\\))", MigrationTool.MIGRATIONCOMMENT + " $1");\r
             // redefine module entry point for some self-relocated modules\r
             wholeline = wholeline.replaceAll (mi.entrypoint + "([^{]*?})", "_ModuleEntryPoint" + "$1");\r
             // remove R8 library contractor\r
@@ -277,7 +278,8 @@ public final class SourceFileReplacer implements Common.ForDoAll {
             //mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing));        \r
             if ((r9thing = MigrationTool.db.getR9Macro(r8thing)) != null) {\r
                 if (wholeline.contains(r8thing)) {\r
-                    wholeline = wholeline.replaceAll(r8thing, r9thing);\r
+                    String findString = "(?<!(?:\\d|\\w))" + r8thing + "(?!(?:\\d|\\w))";\r
+                    wholeline = wholeline.replaceAll(findString, r9thing);\r
                     filemacro.add(new r8tor9(r8thing, r9thing));\r
                 }\r
             }\r