--- a/parser/html/javasrc/AttributeName.java
+++ b/parser/html/javasrc/AttributeName.java
@@ -1,39 +1,40 @@
/*
* Copyright (c) 2008-2011 Mozilla Foundation
*
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
+ * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package nu.validator.htmlparser.impl;
import java.util.Arrays;
import nu.validator.htmlparser.annotation.Local;
import nu.validator.htmlparser.annotation.NoLength;
import nu.validator.htmlparser.annotation.NsUri;
import nu.validator.htmlparser.annotation.Prefix;
import nu.validator.htmlparser.annotation.QName;
+import nu.validator.htmlparser.annotation.Unsigned;
import nu.validator.htmlparser.annotation.Virtual;
import nu.validator.htmlparser.common.Interner;
public final class AttributeName
// Uncomment to regenerate
// implements Comparable<AttributeName>
{
// [NOCPP[
@@ -46,17 +47,17 @@ public final class AttributeName
public static final int IS_XMLNS = (1 << 4);
public static final int CASE_FOLDED = (1 << 5);
public static final int BOOLEAN = (1 << 6);
// ]NOCPP]
-
+
/**
* An array representing no namespace regardless of namespace mode (HTML,
* SVG, MathML, lang-mapping HTML) used.
*/
static final @NoLength @NsUri String[] ALL_NO_NS = { "", "", "",
// [NOCPP[
""
// ]NOCPP]
@@ -165,17 +166,17 @@ public final class AttributeName
return arr;
}
// ]NOCPP]
/**
* An initialization helper for having a one name in the SVG mode and
* another name in the other modes.
- *
+ *
* @param name
* the name for the non-SVG modes
* @param camel
* the name for the SVG mode
* @return the initialized name array
*/
private static @NoLength @Local String[] SVG_DIFFERENT(@Local String name,
@Local String camel) {
@@ -187,17 +188,17 @@ public final class AttributeName
arr[3] = name;
// ]NOCPP]
return arr;
}
/**
* An initialization helper for having a one name in the MathML mode and
* another name in the other modes.
- *
+ *
* @param name
* the name for the non-MathML modes
* @param camel
* the name for the MathML mode
* @return the initialized name array
*/
private static @NoLength @Local String[] MATH_DIFFERENT(@Local String name,
@Local String camel) {
@@ -209,17 +210,17 @@ public final class AttributeName
arr[3] = name;
// ]NOCPP]
return arr;
}
/**
* An initialization helper for having a different local name in the HTML
* mode and the SVG and MathML modes.
- *
+ *
* @param name
* the name for the HTML mode
* @param suffix
* the name for the SVG and MathML modes
* @return the initialized name array
*/
private static @NoLength @Local String[] COLONIFIED_LOCAL(
@Local String name, @Local String suffix) {
@@ -230,17 +231,17 @@ public final class AttributeName
// [NOCPP[
arr[3] = name;
// ]NOCPP]
return arr;
}
/**
* An initialization helper for having the same local name in all modes.
- *
+ *
* @param name
* the name
* @return the initialized name array
*/
static @NoLength @Local String[] SAME_LOCAL(@Local String name) {
@NoLength @Local String[] arr = new String[4];
arr[0] = name;
arr[1] = name;
@@ -248,22 +249,22 @@ public final class AttributeName
// [NOCPP[
arr[3] = name;
// ]NOCPP]
return arr;
}
/**
* Returns an attribute name by buffer.
- *
+ *
* <p>
* C++ ownership: The return value is either released by the caller if the
* attribute is a duplicate or the ownership is transferred to
* HtmlAttributes and released upon clearing or destroying that object.
- *
+ *
* @param buf
* the buffer
* @param offset
* ignored
* @param length
* length of data
* @param checkNcName
* whether to check ncnameness
@@ -271,17 +272,17 @@ public final class AttributeName
*/
static AttributeName nameByBuffer(@NoLength char[] buf, int offset,
int length
// [NOCPP[
, boolean checkNcName
// ]NOCPP]
, Interner interner) {
// XXX deal with offset
- int hash = AttributeName.bufToHash(buf, length);
+ @Unsigned int hash = AttributeName.bufToHash(buf, length);
int index = Arrays.binarySearch(AttributeName.ATTRIBUTE_HASHES, hash);
if (index < 0) {
return AttributeName.createAttributeName(
Portability.newLocalNameFromBuffer(buf, offset, length,
interner)
// [NOCPP[
, checkNcName
// ]NOCPP]
@@ -300,24 +301,24 @@ public final class AttributeName
}
return attributeName;
}
}
/**
* This method has to return a unique integer for each well-known
* lower-cased attribute name.
- *
+ *
* @param buf
* @param len
* @return
*/
- private static int bufToHash(@NoLength char[] buf, int len) {
- int hash2 = 0;
- int hash = len;
+ private static @Unsigned int bufToHash(@NoLength char[] buf, int len) {
+ @Unsigned int hash2 = 0;
+ @Unsigned int hash = len;
hash <<= 5;
hash += buf[0] - 0x60;
int j = len;
for (int i = 0; i < 4 && j > 0; i++) {
j--;
hash <<= 5;
hash += buf[j] - 0x60;
hash2 <<= 6;
@@ -373,46 +374,46 @@ public final class AttributeName
* The qnames indexable by mode.
*/
private final @QName @NoLength String[] qName;
// ]NOCPP]
/**
* The startup-time constructor.
- *
+ *
* @param uri
* the namespace
* @param local
* the local name
* @param prefix
* the prefix
* @param ncname
* the ncnameness
* @param xmlns
* whether this is an xmlns attribute
*/
protected AttributeName(@NsUri @NoLength String[] uri,
@Local @NoLength String[] local, @Prefix @NoLength String[] prefix
// [NOCPP[
, int flags
- // ]NOCPP]
+ // ]NOCPP]
) {
this.uri = uri;
this.local = local;
this.prefix = prefix;
// [NOCPP[
this.qName = COMPUTE_QNAME(local, prefix);
this.flags = flags;
// ]NOCPP]
}
/**
* Creates an <code>AttributeName</code> for a local name.
- *
+ *
* @param name
* the name
* @param checkNcName
* whether to check ncnameness
* @return an <code>AttributeName</code>
*/
private static AttributeName createAttributeName(@Local String name
// [NOCPP[
@@ -444,63 +445,63 @@ public final class AttributeName
*/
@SuppressWarnings("unused") @Virtual private void destructor() {
Portability.deleteArray(local);
}
/**
* Clones the attribute using an interner. Returns <code>this</code> in Java
* and for non-dynamic instances in C++.
- *
+ *
* @param interner
* an interner
* @return a clone
*/
@Virtual public AttributeName cloneAttributeName(Interner interner) {
return this;
}
// [NOCPP[
/**
* Creator for use when the XML violation policy requires an attribute name
* to be changed.
- *
+ *
* @param name
* the name of the attribute to create
*/
static AttributeName create(@Local String name) {
return new AttributeName(AttributeName.ALL_NO_NS,
AttributeName.SAME_LOCAL(name), ALL_NO_PREFIX,
NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
}
/**
* Queries whether this name is an XML 1.0 4th ed. NCName.
- *
+ *
* @param mode
* the SVG/MathML/HTML mode
* @return <code>true</code> if this is an NCName in the given mode
*/
public boolean isNcName(int mode) {
return (flags & (1 << mode)) != 0;
}
/**
* Queries whether this is an <code>xmlns</code> attribute.
- *
+ *
* @return <code>true</code> if this is an <code>xmlns</code> attribute
*/
public boolean isXmlns() {
return (flags & IS_XMLNS) != 0;
}
-
+
/**
* Queries whether this attribute has a case-folded value in the HTML4 mode
* of the parser.
- *
+ *
* @return <code>true</code> if the value is case-folded
*/
boolean isCaseFolded() {
return (flags & CASE_FOLDED) != 0;
}
boolean isBoolean() {
return (flags & BOOLEAN) != 0;
--- a/parser/html/javasrc/ElementName.java
+++ b/parser/html/javasrc/ElementName.java
@@ -22,16 +22,17 @@
package nu.validator.htmlparser.impl;
import java.util.Arrays;
import nu.validator.htmlparser.annotation.Inline;
import nu.validator.htmlparser.annotation.Local;
import nu.validator.htmlparser.annotation.NoLength;
+import nu.validator.htmlparser.annotation.Unsigned;
import nu.validator.htmlparser.annotation.Virtual;
import nu.validator.htmlparser.common.Interner;
public final class ElementName
// uncomment when regenerating self
// implements Comparable<ElementName>
{
@@ -103,17 +104,17 @@ public final class ElementName
return flags & GROUP_MASK;
}
public boolean isCustom() {
return (flags & CUSTOM) != 0;
}
static ElementName elementNameByBuffer(@NoLength char[] buf, int offset, int length, Interner interner) {
- int hash = ElementName.bufToHash(buf, length);
+ @Unsigned int hash = ElementName.bufToHash(buf, length);
int index = Arrays.binarySearch(ElementName.ELEMENT_HASHES, hash);
if (index < 0) {
return new ElementName(Portability.newLocalNameFromBuffer(buf, offset, length, interner));
} else {
ElementName elementName = ElementName.ELEMENT_NAMES[index];
@Local String name = elementName.name;
if (!Portability.localEqualsBuffer(name, buf, offset, length)) {
return new ElementName(Portability.newLocalNameFromBuffer(buf,
@@ -126,18 +127,18 @@ public final class ElementName
/**
* This method has to return a unique integer for each well-known
* lower-cased element name.
*
* @param buf
* @param len
* @return
*/
- private static int bufToHash(@NoLength char[] buf, int len) {
- int hash = len;
+ private static @Unsigned int bufToHash(@NoLength char[] buf, int len) {
+ @Unsigned int hash = len;
hash <<= 5;
hash += buf[0] - 0x60;
int j = len;
for (int i = 0; i < 4 && j > 0; i++) {
j--;
hash <<= 5;
hash += buf[j] - 0x60;
}
--- a/parser/html/nsHtml5AttributeName.cpp
+++ b/parser/html/nsHtml5AttributeName.cpp
@@ -1,27 +1,27 @@
/*
* Copyright (c) 2008-2011 Mozilla Foundation
*
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
+ * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit AttributeName.java instead and regenerate.
*/
@@ -101,35 +101,35 @@ nsHtml5AttributeName::SAME_LOCAL(nsIAtom
arr[1] = name;
arr[2] = name;
return arr;
}
nsHtml5AttributeName*
nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
- int32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
+ uint32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash);
if (index < 0) {
return nsHtml5AttributeName::createAttributeName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner));
} else {
nsHtml5AttributeName* attributeName = nsHtml5AttributeName::ATTRIBUTE_NAMES[index];
nsIAtom* name = attributeName->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML);
if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
return nsHtml5AttributeName::createAttributeName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner));
}
return attributeName;
}
}
-int32_t
+uint32_t
nsHtml5AttributeName::bufToHash(char16_t* buf, int32_t len)
{
- int32_t hash2 = 0;
- int32_t hash = len;
+ uint32_t hash2 = 0;
+ uint32_t hash = len;
hash <<= 5;
hash += buf[0] - 0x60;
int32_t j = len;
for (int32_t i = 0; i < 4 && j > 0; i++) {
j--;
hash <<= 5;
hash += buf[j] - 0x60;
hash2 <<= 6;
--- a/parser/html/nsHtml5AttributeName.h
+++ b/parser/html/nsHtml5AttributeName.h
@@ -1,27 +1,27 @@
/*
* Copyright (c) 2008-2011 Mozilla Foundation
*
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
+ * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit AttributeName.java instead and regenerate.
*/
@@ -71,17 +71,17 @@ class nsHtml5AttributeName
static nsIAtom** XML_PREFIX;
static nsIAtom** SVG_DIFFERENT(nsIAtom* name, nsIAtom* camel);
static nsIAtom** MATH_DIFFERENT(nsIAtom* name, nsIAtom* camel);
static nsIAtom** COLONIFIED_LOCAL(nsIAtom* name, nsIAtom* suffix);
public:
static nsIAtom** SAME_LOCAL(nsIAtom* name);
static nsHtml5AttributeName* nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
private:
- static int32_t bufToHash(char16_t* buf, int32_t len);
+ static uint32_t bufToHash(char16_t* buf, int32_t len);
int32_t* uri;
nsIAtom** local;
nsIAtom** prefix;
protected:
nsHtml5AttributeName(int32_t* uri, nsIAtom** local, nsIAtom** prefix);
private:
static nsHtml5AttributeName* createAttributeName(nsIAtom* name);
public:
--- a/parser/html/nsHtml5ElementName.cpp
+++ b/parser/html/nsHtml5ElementName.cpp
@@ -66,34 +66,34 @@ bool
nsHtml5ElementName::isCustom()
{
return (flags & NS_HTML5ELEMENT_NAME_CUSTOM);
}
nsHtml5ElementName*
nsHtml5ElementName::elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
- int32_t hash = nsHtml5ElementName::bufToHash(buf, length);
+ uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
int32_t index = nsHtml5ElementName::ELEMENT_HASHES.binarySearch(hash);
if (index < 0) {
return new nsHtml5ReleasableElementName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner));
} else {
nsHtml5ElementName* elementName = nsHtml5ElementName::ELEMENT_NAMES[index];
nsIAtom* name = elementName->name;
if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
return new nsHtml5ReleasableElementName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner));
}
return elementName;
}
}
-int32_t
+uint32_t
nsHtml5ElementName::bufToHash(char16_t* buf, int32_t len)
{
- int32_t hash = len;
+ uint32_t hash = len;
hash <<= 5;
hash += buf[0] - 0x60;
int32_t j = len;
for (int32_t i = 0; i < 4 && j > 0; i++) {
j--;
hash <<= 5;
hash += buf[j] - 0x60;
}
--- a/parser/html/nsHtml5ElementName.h
+++ b/parser/html/nsHtml5ElementName.h
@@ -66,17 +66,17 @@ class nsHtml5ElementName
{
return flags;
}
int32_t getGroup();
bool isCustom();
static nsHtml5ElementName* elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
private:
- static int32_t bufToHash(char16_t* buf, int32_t len);
+ static uint32_t bufToHash(char16_t* buf, int32_t len);
nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, int32_t flags);
protected:
explicit nsHtml5ElementName(nsIAtom* name);
public:
virtual void release();
virtual ~nsHtml5ElementName();
virtual nsHtml5ElementName* cloneElementName(nsHtml5AtomTable* interner);
static nsHtml5ElementName* ELT_A;