]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/MigrationTools/org/tianocore/migration/Func.java
Coding Style
[mirror_edk2.git] / Tools / Java / Source / MigrationTools / org / tianocore / migration / Func.java
1 /** @file
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 **/
13 package org.tianocore.migration;
14
15 import java.util.regex.Matcher;
16 import java.util.regex.Pattern;
17
18 public class Func {
19 Func(String r8func, String r8lib, String r9func, String r9lib) {
20 r8funcname = r8func;
21 r8libname = r8lib;
22 r9funcname = r9func;
23 r9libname = r9lib;
24 }
25
26 Func(String[] linecontext) {
27 r8funcname = linecontext[1];
28 r8libname = linecontext[0];
29 r9funcname = linecontext[2];
30 if (r9funcname.contains("n/a")) {
31 r9funcname = "#error Unknown or missing library function in EDKII: "
32 + r8funcname;
33 }
34 r9libname = linecontext[3];
35 }
36
37 public String r8funcname;
38
39 public String r8libname;
40
41 public String r9funcname;
42
43 public String r9libname;
44
45 public static Pattern ptnbrace = Pattern.compile("\\{[^\\{\\}]*\\}",
46 Pattern.MULTILINE);
47
48 public static Pattern ptnfuncc = Pattern.compile(
49 "(?<!->)([a-zA-Z_]\\w*)\\s*\\(", Pattern.MULTILINE);
50
51 public static Pattern ptnfuncd = Pattern.compile(
52 "([a-zA-Z_]\\w*)\\s*\\([^\\)\\(]*\\)\\s*@", Pattern.MULTILINE);
53
54 public static Pattern ptnlowcase = Pattern.compile("[a-z]"); // must be
55 // removed
56
57 private static String reservedwords = "if for pack while switch return sizeof";
58
59 public static String register(Matcher mtr, ModuleInfo mi, Database db) {
60 String temp = null;
61
62 temp = mtr.group(1); // both changed and not changed funcc are
63 // registered , for finding all the non-local
64 // function calls
65 Matcher mtrlowcase = ptnlowcase.matcher(temp); // must be removed , so
66 // the two funcs can be
67 // merged
68 if (!reservedwords.contains(temp) && mtrlowcase.find()) {
69 mi.hashfuncc.add(temp);
70 }
71 return temp;
72 }
73 }