Merge pull request #303 from Parabot/task/thread-getId-redirect

[TASK] Added Thread#getId redirect
This commit is contained in:
Jeroen Ketelaar
2019-05-08 09:11:08 -05:00
committed by GitHub
3 changed files with 90 additions and 86 deletions
@@ -65,4 +65,8 @@ public class ThreadRedirect {
public static boolean isInterrupted(Thread thread) { public static boolean isInterrupted(Thread thread) {
return thread.isInterrupted(); return thread.isInterrupted();
} }
public static long getId(Thread thread) {
return thread.getId();
}
} }
@@ -29,8 +29,8 @@ public class XMLHookParser extends HookParser {
public XMLHookParser(HookFile hookFile) { public XMLHookParser(HookFile hookFile) {
super(hookFile); super(hookFile);
interfaceMap = new HashMap<String, String>(); interfaceMap = new HashMap<>();
constants = new HashMap<String, String>(); constants = new HashMap<>();
try { try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory DocumentBuilderFactory dbFactory = DocumentBuilderFactory
.newInstance(); .newInstance();
@@ -45,48 +45,6 @@ public class XMLHookParser extends HookParser {
} }
} }
private static String resolveDesc(String returnDesc) {
String array = "";
if (returnDesc != null && returnDesc.contains("%s")) {
StringBuilder str = new StringBuilder();
if (returnDesc.startsWith("[")) {
for (int i = 0; i < returnDesc.length(); i++) {
if (returnDesc.charAt(i) == '[') {
array += '[';
}
}
returnDesc = returnDesc.replaceAll("\\[", "");
}
str.append(array)
.append('L')
.append(String.format(returnDesc,
AddInterfaceAdapter.getAccessorPackage()))
.append(";");
returnDesc = str.toString();
}
return returnDesc;
}
private static final boolean isSet(String tag, Element element) {
return element.getElementsByTagName(tag).getLength() > 0;
}
private static final String getValue(String tag, Element element) {
if (element.getElementsByTagName(tag).item(0) == null) {
throw new NullPointerException("MISSING HOOK TAG: The '" + tag + "' xml tag is missing from one of the hooks of type: " + element.getParentNode().getNodeName());
}
NodeList nodes = element.getElementsByTagName(tag).item(0)
.getChildNodes();
if (nodes.getLength() == 0 || nodes.item(0) == null) {
if (Core.inVerboseMode()) {
System.err.println("WARNING: Invalid Hook " + tag + " subnode. Tag is missing or empty?");
}
return "";
}
Node node = (Node) nodes.item(0);
return node.getNodeValue();
}
@Override @Override
public Interface[] getInterfaces() { public Interface[] getInterfaces() {
parsedInterfaces = true; parsedInterfaces = true;
@@ -468,4 +426,46 @@ public class XMLHookParser extends HookParser {
return callbackList.toArray(new Callback[callbackList.size()]); return callbackList.toArray(new Callback[callbackList.size()]);
} }
private static String resolveDesc(String returnDesc) {
String array = "";
if (returnDesc != null && returnDesc.contains("%s")) {
StringBuilder str = new StringBuilder();
if (returnDesc.startsWith("[")) {
for (int i = 0; i < returnDesc.length(); i++) {
if (returnDesc.charAt(i) == '[') {
array += '[';
}
}
returnDesc = returnDesc.replaceAll("\\[", "");
}
str.append(array)
.append('L')
.append(String.format(returnDesc,
AddInterfaceAdapter.getAccessorPackage()))
.append(";");
returnDesc = str.toString();
}
return returnDesc;
}
private static final boolean isSet(String tag, Element element) {
return element.getElementsByTagName(tag).getLength() > 0;
}
private static final String getValue(String tag, Element element) {
if (element.getElementsByTagName(tag).item(0) == null) {
throw new NullPointerException("MISSING HOOK TAG: The '" + tag + "' xml tag is missing from one of the hooks of type: " + element.getParentNode().getNodeName());
}
NodeList nodes = element.getElementsByTagName(tag).item(0)
.getChildNodes();
if (nodes.getLength() == 0 || nodes.item(0) == null) {
if (Core.inVerboseMode()) {
System.err.println("WARNING: Invalid Hook " + tag + " subnode. Tag is missing or empty?");
}
return "";
}
Node node = (Node) nodes.item(0);
return node.getNodeValue();
}
} }