mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-06 15:27:30 +09:00
Bug 1347737 - Introduce a new non-heap-allocated type for holding nsStringBuffer* in the HTML parser. (java htmlparser)
This commit is contained in:
parent
bdd222ff43
commit
38d498e499
2 changed files with 38 additions and 33 deletions
|
|
@ -97,7 +97,7 @@ public class CppTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] TREE_BUILDER_INCLUDES = { "nsContentUtils",
|
private static final String[] TREE_BUILDER_INCLUDES = { "nsContentUtils",
|
||||||
"nsIAtom", "nsHtml5AtomTable", "nsITimer", "nsString",
|
"nsIAtom", "nsHtml5AtomTable", "nsITimer", "nsHtml5String",
|
||||||
"nsNameSpaceManager", "nsIContent", "nsTraceRefcnt", "jArray",
|
"nsNameSpaceManager", "nsIContent", "nsTraceRefcnt", "jArray",
|
||||||
"nsHtml5DocumentMode", "nsHtml5ArrayCopy", "nsHtml5Parser",
|
"nsHtml5DocumentMode", "nsHtml5ArrayCopy", "nsHtml5Parser",
|
||||||
"nsHtml5Atoms", "nsHtml5TreeOperation", "nsHtml5StateSnapshot",
|
"nsHtml5Atoms", "nsHtml5TreeOperation", "nsHtml5StateSnapshot",
|
||||||
|
|
@ -107,14 +107,14 @@ public class CppTypes {
|
||||||
"mozilla/Likely", "nsIContentHandle", "nsHtml5OplessBuilder" };
|
"mozilla/Likely", "nsIContentHandle", "nsHtml5OplessBuilder" };
|
||||||
|
|
||||||
private static final String[] TOKENIZER_INCLUDES = { "nsIAtom",
|
private static final String[] TOKENIZER_INCLUDES = { "nsIAtom",
|
||||||
"nsHtml5AtomTable", "nsString", "nsIContent", "nsTraceRefcnt",
|
"nsHtml5AtomTable", "nsHtml5String", "nsIContent", "nsTraceRefcnt",
|
||||||
"jArray", "nsHtml5DocumentMode", "nsHtml5ArrayCopy",
|
"jArray", "nsHtml5DocumentMode", "nsHtml5ArrayCopy",
|
||||||
"nsHtml5NamedCharacters", "nsHtml5NamedCharactersAccel",
|
"nsHtml5NamedCharacters", "nsHtml5NamedCharactersAccel",
|
||||||
"nsHtml5Atoms", "nsAHtml5TreeBuilderState", "nsHtml5Macros",
|
"nsHtml5Atoms", "nsAHtml5TreeBuilderState", "nsHtml5Macros",
|
||||||
"nsHtml5Highlighter", "nsHtml5TokenizerLoopPolicies" };
|
"nsHtml5Highlighter", "nsHtml5TokenizerLoopPolicies" };
|
||||||
|
|
||||||
private static final String[] INCLUDES = { "nsIAtom", "nsHtml5AtomTable",
|
private static final String[] INCLUDES = { "nsIAtom", "nsHtml5AtomTable",
|
||||||
"nsString", "nsNameSpaceManager", "nsIContent", "nsTraceRefcnt",
|
"nsHtml5String", "nsNameSpaceManager", "nsIContent", "nsTraceRefcnt",
|
||||||
"jArray", "nsHtml5ArrayCopy", "nsAHtml5TreeBuilderState",
|
"jArray", "nsHtml5ArrayCopy", "nsAHtml5TreeBuilderState",
|
||||||
"nsHtml5Atoms", "nsHtml5ByteReadable", "nsIUnicodeDecoder",
|
"nsHtml5Atoms", "nsHtml5ByteReadable", "nsIUnicodeDecoder",
|
||||||
"nsHtml5Macros", "nsIContentHandle" };
|
"nsHtml5Macros", "nsIContentHandle" };
|
||||||
|
|
@ -181,7 +181,7 @@ public class CppTypes {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only used for named characters.
|
* Only used for named characters.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String unsignedShortType() {
|
public String unsignedShortType() {
|
||||||
|
|
@ -193,7 +193,7 @@ public class CppTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String stringType() {
|
public String stringType() {
|
||||||
return "nsString*";
|
return "nsHtml5String";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String localType() {
|
public String localType() {
|
||||||
|
|
@ -422,7 +422,7 @@ public class CppTypes {
|
||||||
public String unlikely() {
|
public String unlikely() {
|
||||||
return "MOZ_UNLIKELY";
|
return "MOZ_UNLIKELY";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String completedCharacterReference() {
|
public String completedCharacterReference() {
|
||||||
return "P::completedNamedCharacterReference(mViewSource)";
|
return "P::completedNamedCharacterReference(mViewSource)";
|
||||||
}
|
}
|
||||||
|
|
@ -434,7 +434,7 @@ public class CppTypes {
|
||||||
public String assertionMacro() {
|
public String assertionMacro() {
|
||||||
return "MOZ_ASSERT";
|
return "MOZ_ASSERT";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String releaseAssertionMacro() {
|
public String releaseAssertionMacro() {
|
||||||
return "MOZ_RELEASE_ASSERT";
|
return "MOZ_RELEASE_ASSERT";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2007 Júlio Vilmar Gesser.
|
* Copyright (C) 2007 Júlio Vilmar Gesser.
|
||||||
* Copyright (C) 2008 Mozilla Foundation
|
* Copyright (C) 2008 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* This file is part of HTML Parser C++ Translator. It was derived from DumpVisitor
|
* This file is part of HTML Parser C++ Translator. It was derived from DumpVisitor
|
||||||
* which was part of Java 1.5 parser and Abstract Syntax Tree and came with the following notice:
|
* which was part of Java 1.5 parser and Abstract Syntax Tree and came with the following notice:
|
||||||
*
|
*
|
||||||
|
|
@ -23,6 +23,13 @@
|
||||||
*/
|
*/
|
||||||
package nu.validator.htmlparser.cpptranslate;
|
package nu.validator.htmlparser.cpptranslate;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import japa.parser.ast.BlockComment;
|
import japa.parser.ast.BlockComment;
|
||||||
import japa.parser.ast.CompilationUnit;
|
import japa.parser.ast.CompilationUnit;
|
||||||
import japa.parser.ast.ImportDeclaration;
|
import japa.parser.ast.ImportDeclaration;
|
||||||
|
|
@ -110,13 +117,6 @@ import japa.parser.ast.type.Type;
|
||||||
import japa.parser.ast.type.VoidType;
|
import japa.parser.ast.type.VoidType;
|
||||||
import japa.parser.ast.type.WildcardType;
|
import japa.parser.ast.type.WildcardType;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Julio Vilmar Gesser
|
* @author Julio Vilmar Gesser
|
||||||
* @author Henri Sivonen
|
* @author Henri Sivonen
|
||||||
|
|
@ -158,7 +158,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
indented = false;
|
indented = false;
|
||||||
buf.append(arg);
|
buf.append(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print(String arg) {
|
public void print(String arg) {
|
||||||
if (!indented) {
|
if (!indented) {
|
||||||
makeIndent();
|
makeIndent();
|
||||||
|
|
@ -187,7 +187,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportErrorReporting = true;
|
private boolean supportErrorReporting = true;
|
||||||
|
|
||||||
protected SourcePrinter printer = new SourcePrinter();
|
protected SourcePrinter printer = new SourcePrinter();
|
||||||
|
|
||||||
private SourcePrinter staticInitializerPrinter = new SourcePrinter();
|
private SourcePrinter staticInitializerPrinter = new SourcePrinter();
|
||||||
|
|
@ -221,11 +221,11 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
private Set<String> labels = null;
|
private Set<String> labels = null;
|
||||||
|
|
||||||
private boolean destructor;
|
private boolean destructor;
|
||||||
|
|
||||||
protected boolean inStatic = false;
|
protected boolean inStatic = false;
|
||||||
|
|
||||||
private boolean reportTransitions = false;
|
private boolean reportTransitions = false;
|
||||||
|
|
||||||
private int stateLoopCallCount = 0;
|
private int stateLoopCallCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -571,7 +571,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < n.getArrayCount(); i++) {
|
for (int i = 0; i < n.getArrayCount(); i++) {
|
||||||
if (inStatic) {
|
if (inStatic) {
|
||||||
printer.print(cppTypes.staticArrayTemplate());
|
printer.print(cppTypes.staticArrayTemplate());
|
||||||
} else {
|
} else {
|
||||||
if (auto()) {
|
if (auto()) {
|
||||||
printer.print(cppTypes.autoArrayTemplate());
|
printer.print(cppTypes.autoArrayTemplate());
|
||||||
|
|
@ -644,10 +644,10 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
printer.print("::");
|
printer.print("::");
|
||||||
declarator.getId().accept(this, arg);
|
declarator.getId().accept(this, arg);
|
||||||
|
|
||||||
printer.print(" = ");
|
printer.print(" = ");
|
||||||
|
|
||||||
declarator.getInit().accept(this, arg);
|
declarator.getInit().accept(this, arg);
|
||||||
|
|
||||||
printer.printLn(";");
|
printer.printLn(";");
|
||||||
printer = staticInitializerPrinter;
|
printer = staticInitializerPrinter;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -660,7 +660,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
|
|
||||||
printer.printLn(" = 0;");
|
printer.printLn(" = 0;");
|
||||||
printer = staticInitializerPrinter;
|
printer = staticInitializerPrinter;
|
||||||
|
|
||||||
staticReleases.add("delete[] "
|
staticReleases.add("delete[] "
|
||||||
+ declarator.getId().getName());
|
+ declarator.getId().getName());
|
||||||
|
|
||||||
|
|
@ -686,7 +686,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
declarator.getId().accept(this, arg);
|
declarator.getId().accept(this, arg);
|
||||||
printer.print("_DATA[] = ");
|
printer.print("_DATA[] = ");
|
||||||
declarator.getInit().accept(this, arg);
|
declarator.getInit().accept(this, arg);
|
||||||
printer.printLn(";");
|
printer.printLn(";");
|
||||||
printer.print(cppTypes.staticArrayTemplate());
|
printer.print(cppTypes.staticArrayTemplate());
|
||||||
printer.print("<");
|
printer.print("<");
|
||||||
suppressPointer = true;
|
suppressPointer = true;
|
||||||
|
|
@ -751,7 +751,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
printer.printLn(";");
|
printer.printLn(";");
|
||||||
printer = staticInitializerPrinter;
|
printer = staticInitializerPrinter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("AttributeName".equals(n.getType().toString())) {
|
if ("AttributeName".equals(n.getType().toString())) {
|
||||||
printer.print("ATTR_");
|
printer.print("ATTR_");
|
||||||
staticReleases.add("delete ATTR_"
|
staticReleases.add("delete ATTR_"
|
||||||
|
|
@ -1257,6 +1257,10 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
&& "Portability".equals(n.getScope().toString())) {
|
&& "Portability".equals(n.getScope().toString())) {
|
||||||
n.getArgs().get(0).accept(this, arg);
|
n.getArgs().get(0).accept(this, arg);
|
||||||
printer.print(".release()");
|
printer.print(".release()");
|
||||||
|
} else if ("releaseString".equals(n.getName())
|
||||||
|
&& "Portability".equals(n.getScope().toString())) {
|
||||||
|
n.getArgs().get(0).accept(this, arg);
|
||||||
|
printer.print(".Release()");
|
||||||
} else if ("deleteArray".equals(n.getName())
|
} else if ("deleteArray".equals(n.getName())
|
||||||
&& "Portability".equals(n.getScope().toString())) {
|
&& "Portability".equals(n.getScope().toString())) {
|
||||||
printer.print("delete[] ");
|
printer.print("delete[] ");
|
||||||
|
|
@ -1554,6 +1558,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
|| n.getName().startsWith("maybeWarn")
|
|| n.getName().startsWith("maybeWarn")
|
||||||
|| n.getName().startsWith("note")
|
|| n.getName().startsWith("note")
|
||||||
|| "releaseArray".equals(n.getName())
|
|| "releaseArray".equals(n.getName())
|
||||||
|
|| "releaseString".equals(n.getName())
|
||||||
|| "deleteArray".equals(n.getName())
|
|| "deleteArray".equals(n.getName())
|
||||||
|| "delete".equals(n.getName())) {
|
|| "delete".equals(n.getName())) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1588,7 +1593,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
printer.printLn();
|
printer.printLn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printTypeParameters(n.getTypeParameters(), arg);
|
printTypeParameters(n.getTypeParameters(), arg);
|
||||||
if (n.getTypeParameters() != null) {
|
if (n.getTypeParameters() != null) {
|
||||||
printer.print(" ");
|
printer.print(" ");
|
||||||
|
|
@ -1769,7 +1774,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Bad assertion message string.");
|
throw new RuntimeException("Bad assertion message string.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printer.print("\"");
|
printer.print("\"");
|
||||||
}
|
}
|
||||||
printer.print(");");
|
printer.print(");");
|
||||||
|
|
@ -1857,7 +1862,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
printer.print(cppTypes.transition());
|
printer.print(cppTypes.transition());
|
||||||
printer.print("(");
|
printer.print("(");
|
||||||
printer.print(cppTypes.firstTransitionArg());
|
printer.print(cppTypes.firstTransitionArg());
|
||||||
printer.print(", ");
|
printer.print(", ");
|
||||||
args.get(1).accept(this, arg);
|
args.get(1).accept(this, arg);
|
||||||
printer.print(", ");
|
printer.print(", ");
|
||||||
args.get(2).accept(this, arg);
|
args.get(2).accept(this, arg);
|
||||||
|
|
@ -1884,7 +1889,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCompletedCharacterReference(Expression e) {
|
private boolean isCompletedCharacterReference(Expression e) {
|
||||||
if (!reportTransitions) {
|
if (!reportTransitions) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1898,7 +1903,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDroppedExpression(Expression e) {
|
private boolean isDroppedExpression(Expression e) {
|
||||||
if (e instanceof MethodCallExpr) {
|
if (e instanceof MethodCallExpr) {
|
||||||
MethodCallExpr methodCallExpr = (MethodCallExpr) e;
|
MethodCallExpr methodCallExpr = (MethodCallExpr) e;
|
||||||
|
|
@ -2130,7 +2135,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
if (statements != null && statements.size() == 1) {
|
if (statements != null && statements.size() == 1) {
|
||||||
statements.get(0).accept(this, arg);
|
statements.get(0).accept(this, arg);
|
||||||
} else {
|
} else {
|
||||||
then.accept(this, arg);
|
then.accept(this, arg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
then.accept(this, arg);
|
then.accept(this, arg);
|
||||||
|
|
@ -2191,7 +2196,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void formatCondition(Expression expr, LocalSymbolTable arg) {
|
private void formatCondition(Expression expr, LocalSymbolTable arg) {
|
||||||
if (expr instanceof BinaryExpr) {
|
if (expr instanceof BinaryExpr) {
|
||||||
BinaryExpr binExpr = (BinaryExpr) expr;
|
BinaryExpr binExpr = (BinaryExpr) expr;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue