am 2ffa4aab
: Merge "Use char16_t for char things."
* commit '2ffa4aabd76353a907ee89a3e0c6f1961237f257': Use char16_t for char things.
This commit is contained in:
@ -499,7 +499,7 @@ void TextLayoutShaper::computeValues(const SkPaint* paint, const UChar* chars,
|
||||
#define HB_InvalidCodePoint ~0u
|
||||
|
||||
hb_codepoint_t
|
||||
utf16_to_code_point(const uint16_t *chars, size_t len, ssize_t *iter) {
|
||||
utf16_to_code_point(const char16_t *chars, size_t len, ssize_t *iter) {
|
||||
const uint16_t v = chars[(*iter)++];
|
||||
if (HB_IsHighSurrogate(v)) {
|
||||
// surrogate pair
|
||||
@ -526,7 +526,7 @@ utf16_to_code_point(const uint16_t *chars, size_t len, ssize_t *iter) {
|
||||
}
|
||||
|
||||
hb_codepoint_t
|
||||
utf16_to_code_point_prev(const uint16_t *chars, size_t len, ssize_t *iter) {
|
||||
utf16_to_code_point_prev(const char16_t *chars, size_t len, ssize_t *iter) {
|
||||
const uint16_t v = chars[(*iter)--];
|
||||
if (HB_IsLowSurrogate(v)) {
|
||||
// surrogate pair
|
||||
@ -567,7 +567,7 @@ hb_script_t code_point_to_script(hb_codepoint_t codepoint) {
|
||||
}
|
||||
|
||||
bool
|
||||
hb_utf16_script_run_next(ScriptRun* run, const uint16_t *chars, size_t len, ssize_t *iter) {
|
||||
hb_utf16_script_run_next(ScriptRun* run, const char16_t *chars, size_t len, ssize_t *iter) {
|
||||
if (size_t(*iter) == len)
|
||||
return false;
|
||||
|
||||
@ -610,7 +610,7 @@ hb_utf16_script_run_next(ScriptRun* run, const uint16_t *chars, size_t len, ssiz
|
||||
}
|
||||
|
||||
bool
|
||||
hb_utf16_script_run_prev(ScriptRun* run, const uint16_t *chars, size_t len, ssize_t *iter) {
|
||||
hb_utf16_script_run_prev(ScriptRun* run, const char16_t *chars, size_t len, ssize_t *iter) {
|
||||
if (*iter == -1)
|
||||
return false;
|
||||
|
||||
|
@ -669,25 +669,25 @@ public:
|
||||
|
||||
// These are available for all nodes:
|
||||
int32_t getCommentID() const;
|
||||
const uint16_t* getComment(size_t* outLen) const;
|
||||
const char16_t* getComment(size_t* outLen) const;
|
||||
uint32_t getLineNumber() const;
|
||||
|
||||
// This is available for TEXT:
|
||||
int32_t getTextID() const;
|
||||
const uint16_t* getText(size_t* outLen) const;
|
||||
const char16_t* getText(size_t* outLen) const;
|
||||
ssize_t getTextValue(Res_value* outValue) const;
|
||||
|
||||
// These are available for START_NAMESPACE and END_NAMESPACE:
|
||||
int32_t getNamespacePrefixID() const;
|
||||
const uint16_t* getNamespacePrefix(size_t* outLen) const;
|
||||
const char16_t* getNamespacePrefix(size_t* outLen) const;
|
||||
int32_t getNamespaceUriID() const;
|
||||
const uint16_t* getNamespaceUri(size_t* outLen) const;
|
||||
const char16_t* getNamespaceUri(size_t* outLen) const;
|
||||
|
||||
// These are available for START_TAG and END_TAG:
|
||||
int32_t getElementNamespaceID() const;
|
||||
const uint16_t* getElementNamespace(size_t* outLen) const;
|
||||
const char16_t* getElementNamespace(size_t* outLen) const;
|
||||
int32_t getElementNameID() const;
|
||||
const uint16_t* getElementName(size_t* outLen) const;
|
||||
const char16_t* getElementName(size_t* outLen) const;
|
||||
|
||||
// Remaining methods are for retrieving information about attributes
|
||||
// associated with a START_TAG:
|
||||
@ -696,10 +696,10 @@ public:
|
||||
|
||||
// Returns -1 if no namespace, -2 if idx out of range.
|
||||
int32_t getAttributeNamespaceID(size_t idx) const;
|
||||
const uint16_t* getAttributeNamespace(size_t idx, size_t* outLen) const;
|
||||
const char16_t* getAttributeNamespace(size_t idx, size_t* outLen) const;
|
||||
|
||||
int32_t getAttributeNameID(size_t idx) const;
|
||||
const uint16_t* getAttributeName(size_t idx, size_t* outLen) const;
|
||||
const char16_t* getAttributeName(size_t idx, size_t* outLen) const;
|
||||
uint32_t getAttributeNameResID(size_t idx) const;
|
||||
|
||||
// These will work only if the underlying string pool is UTF-8.
|
||||
@ -707,7 +707,7 @@ public:
|
||||
const char* getAttributeName8(size_t idx, size_t* outLen) const;
|
||||
|
||||
int32_t getAttributeValueStringID(size_t idx) const;
|
||||
const uint16_t* getAttributeStringValue(size_t idx, size_t* outLen) const;
|
||||
const char16_t* getAttributeStringValue(size_t idx, size_t* outLen) const;
|
||||
|
||||
int32_t getAttributeDataType(size_t idx) const;
|
||||
int32_t getAttributeData(size_t idx) const;
|
||||
@ -1566,7 +1566,7 @@ public:
|
||||
size_t defPackageLen = 0,
|
||||
uint32_t* outTypeSpecFlags = NULL) const;
|
||||
|
||||
static bool expandResourceRef(const uint16_t* refStr, size_t refLen,
|
||||
static bool expandResourceRef(const char16_t* refStr, size_t refLen,
|
||||
String16* outPackage,
|
||||
String16* outType,
|
||||
String16* outName,
|
||||
|
@ -76,9 +76,9 @@ inline int isspace16(char16_t c) {
|
||||
// range checked; guaranteed to NUL-terminate within the stated number of available slots
|
||||
// NOTE: if this truncates the dst string due to running out of space, no attempt is
|
||||
// made to avoid splitting surrogate pairs.
|
||||
static void strcpy16_dtoh(uint16_t* dst, const uint16_t* src, size_t avail)
|
||||
static void strcpy16_dtoh(char16_t* dst, const char16_t* src, size_t avail)
|
||||
{
|
||||
uint16_t* last = dst + avail - 1;
|
||||
char16_t* last = dst + avail - 1;
|
||||
while (*src && (dst < last)) {
|
||||
char16_t s = dtohs(*src);
|
||||
*dst++ = s;
|
||||
@ -584,7 +584,7 @@ decodeLength(const uint8_t** str)
|
||||
return len;
|
||||
}
|
||||
|
||||
const uint16_t* ResStringPool::stringAt(size_t idx, size_t* u16len) const
|
||||
const char16_t* ResStringPool::stringAt(size_t idx, size_t* u16len) const
|
||||
{
|
||||
if (mError == NO_ERROR && idx < mHeader->stringCount) {
|
||||
const bool isUTF8 = (mHeader->flags&ResStringPool_header::UTF8_FLAG) != 0;
|
||||
@ -903,7 +903,7 @@ int32_t ResXMLParser::getCommentID() const
|
||||
return mCurNode != NULL ? dtohl(mCurNode->comment.index) : -1;
|
||||
}
|
||||
|
||||
const uint16_t* ResXMLParser::getComment(size_t* outLen) const
|
||||
const char16_t* ResXMLParser::getComment(size_t* outLen) const
|
||||
{
|
||||
int32_t id = getCommentID();
|
||||
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
||||
@ -922,7 +922,7 @@ int32_t ResXMLParser::getTextID() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
const uint16_t* ResXMLParser::getText(size_t* outLen) const
|
||||
const char16_t* ResXMLParser::getText(size_t* outLen) const
|
||||
{
|
||||
int32_t id = getTextID();
|
||||
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
||||
@ -945,7 +945,7 @@ int32_t ResXMLParser::getNamespacePrefixID() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
const uint16_t* ResXMLParser::getNamespacePrefix(size_t* outLen) const
|
||||
const char16_t* ResXMLParser::getNamespacePrefix(size_t* outLen) const
|
||||
{
|
||||
int32_t id = getNamespacePrefixID();
|
||||
//printf("prefix=%d event=%p\n", id, mEventCode);
|
||||
@ -960,7 +960,7 @@ int32_t ResXMLParser::getNamespaceUriID() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
const uint16_t* ResXMLParser::getNamespaceUri(size_t* outLen) const
|
||||
const char16_t* ResXMLParser::getNamespaceUri(size_t* outLen) const
|
||||
{
|
||||
int32_t id = getNamespaceUriID();
|
||||
//printf("uri=%d event=%p\n", id, mEventCode);
|
||||
@ -978,7 +978,7 @@ int32_t ResXMLParser::getElementNamespaceID() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
const uint16_t* ResXMLParser::getElementNamespace(size_t* outLen) const
|
||||
const char16_t* ResXMLParser::getElementNamespace(size_t* outLen) const
|
||||
{
|
||||
int32_t id = getElementNamespaceID();
|
||||
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
||||
@ -995,7 +995,7 @@ int32_t ResXMLParser::getElementNameID() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
const uint16_t* ResXMLParser::getElementName(size_t* outLen) const
|
||||
const char16_t* ResXMLParser::getElementName(size_t* outLen) const
|
||||
{
|
||||
int32_t id = getElementNameID();
|
||||
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
||||
@ -1024,7 +1024,7 @@ int32_t ResXMLParser::getAttributeNamespaceID(size_t idx) const
|
||||
return -2;
|
||||
}
|
||||
|
||||
const uint16_t* ResXMLParser::getAttributeNamespace(size_t idx, size_t* outLen) const
|
||||
const char16_t* ResXMLParser::getAttributeNamespace(size_t idx, size_t* outLen) const
|
||||
{
|
||||
int32_t id = getAttributeNamespaceID(idx);
|
||||
//printf("attribute namespace=%d idx=%d event=%p\n", id, idx, mEventCode);
|
||||
@ -1055,7 +1055,7 @@ int32_t ResXMLParser::getAttributeNameID(size_t idx) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
const uint16_t* ResXMLParser::getAttributeName(size_t idx, size_t* outLen) const
|
||||
const char16_t* ResXMLParser::getAttributeName(size_t idx, size_t* outLen) const
|
||||
{
|
||||
int32_t id = getAttributeNameID(idx);
|
||||
//printf("attribute name=%d idx=%d event=%p\n", id, idx, mEventCode);
|
||||
@ -1095,7 +1095,7 @@ int32_t ResXMLParser::getAttributeValueStringID(size_t idx) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
const uint16_t* ResXMLParser::getAttributeStringValue(size_t idx, size_t* outLen) const
|
||||
const char16_t* ResXMLParser::getAttributeStringValue(size_t idx, size_t* outLen) const
|
||||
{
|
||||
int32_t id = getAttributeValueStringID(idx);
|
||||
//XML_NOISY(printf("getAttributeValue 0x%x=0x%x\n", idx, id));
|
||||
@ -4128,7 +4128,7 @@ nope:
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ResTable::expandResourceRef(const uint16_t* refStr, size_t refLen,
|
||||
bool ResTable::expandResourceRef(const char16_t* refStr, size_t refLen,
|
||||
String16* outPackage,
|
||||
String16* outType,
|
||||
String16* outName,
|
||||
|
@ -253,7 +253,7 @@ String8 getAttribute(const ResXMLTree& tree, const char* ns,
|
||||
}
|
||||
}
|
||||
size_t len;
|
||||
const uint16_t* str = tree.getAttributeStringValue(idx, &len);
|
||||
const char16_t* str = tree.getAttributeStringValue(idx, &len);
|
||||
return str ? String8(str, len) : String8();
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ static String8 getAttribute(const ResXMLTree& tree, uint32_t attrRes, String8* o
|
||||
}
|
||||
}
|
||||
size_t len;
|
||||
const uint16_t* str = tree.getAttributeStringValue(idx, &len);
|
||||
const char16_t* str = tree.getAttributeStringValue(idx, &len);
|
||||
return str ? String8(str, len) : String8();
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ static String8 getResolvedAttribute(const ResTable* resTable, const ResXMLTree&
|
||||
if (tree.getAttributeValue(idx, &value) != NO_ERROR) {
|
||||
if (value.dataType == Res_value::TYPE_STRING) {
|
||||
size_t len;
|
||||
const uint16_t* str = tree.getAttributeStringValue(idx, &len);
|
||||
const char16_t* str = tree.getAttributeStringValue(idx, &len);
|
||||
return str ? String8(str, len) : String8();
|
||||
}
|
||||
resTable->resolveReference(&value, 0);
|
||||
|
@ -250,7 +250,7 @@ static status_t parsePackage(Bundle* bundle, const sp<AaptAssets>& assets,
|
||||
ssize_t minSdkIndex = block.indexOfAttribute(RESOURCES_ANDROID_NAMESPACE,
|
||||
"minSdkVersion");
|
||||
if (minSdkIndex >= 0) {
|
||||
const uint16_t* minSdk16 = block.getAttributeStringValue(minSdkIndex, &len);
|
||||
const char16_t* minSdk16 = block.getAttributeStringValue(minSdkIndex, &len);
|
||||
const char* minSdk8 = strdup(String8(minSdk16).string());
|
||||
bundle->setManifestMinSdkVersion(minSdk8);
|
||||
}
|
||||
@ -456,7 +456,7 @@ static int validateAttr(const String8& path, const ResTable& table,
|
||||
size_t len;
|
||||
|
||||
ssize_t index = parser.indexOfAttribute(ns, attr);
|
||||
const uint16_t* str;
|
||||
const char16_t* str;
|
||||
Res_value value;
|
||||
if (index >= 0 && parser.getAttributeValue(index, &value) >= 0) {
|
||||
const ResStringPool* pool = &parser.getStrings();
|
||||
@ -1422,7 +1422,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
|
||||
}
|
||||
size_t len;
|
||||
ssize_t index = block.indexOfAttribute(RESOURCES_ANDROID_NAMESPACE, "name");
|
||||
const uint16_t* id = block.getAttributeStringValue(index, &len);
|
||||
const char16_t* id = block.getAttributeStringValue(index, &len);
|
||||
if (id == NULL) {
|
||||
fprintf(stderr, "%s:%d: missing name attribute in element <%s>.\n",
|
||||
manifestPath.string(), block.getLineNumber(),
|
||||
@ -1465,7 +1465,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
|
||||
hasErrors = true;
|
||||
}
|
||||
syms->addStringSymbol(String8(e), idStr, srcPos);
|
||||
const uint16_t* cmt = block.getComment(&len);
|
||||
const char16_t* cmt = block.getComment(&len);
|
||||
if (cmt != NULL && *cmt != 0) {
|
||||
//printf("Comment of %s: %s\n", String8(e).string(),
|
||||
// String8(cmt).string());
|
||||
|
@ -388,7 +388,7 @@ static status_t compileAttribute(const sp<AaptFile>& in,
|
||||
|
||||
ssize_t l10nIdx = block.indexOfAttribute(NULL, "localization");
|
||||
if (l10nIdx >= 0) {
|
||||
const uint16_t* str = block.getAttributeStringValue(l10nIdx, &len);
|
||||
const char16_t* str = block.getAttributeStringValue(l10nIdx, &len);
|
||||
bool error;
|
||||
uint32_t l10n_required = parse_flags(str, len, l10nRequiredFlags, &error);
|
||||
if (error) {
|
||||
@ -1323,7 +1323,7 @@ status_t compileResourceFile(Bundle* bundle,
|
||||
size_t n = block.getAttributeCount();
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
size_t length;
|
||||
const uint16_t* attr = block.getAttributeName(i, &length);
|
||||
const char16_t* attr = block.getAttributeName(i, &length);
|
||||
if (strcmp16(attr, name16.string()) == 0) {
|
||||
name.setTo(block.getAttributeStringValue(i, &length));
|
||||
} else if (strcmp16(attr, translatable16.string()) == 0) {
|
||||
@ -1439,14 +1439,14 @@ status_t compileResourceFile(Bundle* bundle,
|
||||
// translatable.
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
size_t length;
|
||||
const uint16_t* attr = block.getAttributeName(i, &length);
|
||||
const char16_t* attr = block.getAttributeName(i, &length);
|
||||
if (strcmp16(attr, formatted16.string()) == 0) {
|
||||
const uint16_t* value = block.getAttributeStringValue(i, &length);
|
||||
const char16_t* value = block.getAttributeStringValue(i, &length);
|
||||
if (strcmp16(value, false16.string()) == 0) {
|
||||
curIsFormatted = false;
|
||||
}
|
||||
} else if (strcmp16(attr, translatable16.string()) == 0) {
|
||||
const uint16_t* value = block.getAttributeStringValue(i, &length);
|
||||
const char16_t* value = block.getAttributeStringValue(i, &length);
|
||||
if (strcmp16(value, false16.string()) == 0) {
|
||||
isTranslatable = false;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#define NOISY(x) //x
|
||||
|
||||
void strcpy16_htod(uint16_t* dst, const uint16_t* src)
|
||||
void strcpy16_htod(char16_t* dst, const char16_t* src)
|
||||
{
|
||||
while (*src) {
|
||||
char16_t s = htods(*src);
|
||||
@ -447,9 +447,9 @@ status_t StringPool::writeStringBlock(const sp<AaptFile>& pool)
|
||||
|
||||
strncpy((char*)strings, encStr, encSize+1);
|
||||
} else {
|
||||
uint16_t* strings = (uint16_t*)dat;
|
||||
char16_t* strings = (char16_t*)dat;
|
||||
|
||||
ENCODE_LENGTH(strings, sizeof(uint16_t), strSize)
|
||||
ENCODE_LENGTH(strings, sizeof(char16_t), strSize)
|
||||
|
||||
strcpy16_htod(strings, ent.value);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ using namespace android;
|
||||
|
||||
#define PRINT_STRING_METRICS 0
|
||||
|
||||
void strcpy16_htod(uint16_t* dst, const uint16_t* src);
|
||||
void strcpy16_htod(char16_t* dst, const char16_t* src);
|
||||
|
||||
void printStringPool(const ResStringPool* pool);
|
||||
|
||||
|
@ -234,9 +234,9 @@ status_t parseStyledString(Bundle* bundle,
|
||||
const String8 element8(element16);
|
||||
|
||||
size_t nslen;
|
||||
const uint16_t* ns = inXml->getElementNamespace(&nslen);
|
||||
const char16_t* ns = inXml->getElementNamespace(&nslen);
|
||||
if (ns == NULL) {
|
||||
ns = (const uint16_t*)"\0\0";
|
||||
ns = (const char16_t*)"\0\0";
|
||||
nslen = 0;
|
||||
}
|
||||
const String8 nspace(String16(ns, nslen));
|
||||
@ -291,9 +291,9 @@ moveon:
|
||||
|
||||
} else if (code == ResXMLTree::END_TAG) {
|
||||
size_t nslen;
|
||||
const uint16_t* ns = inXml->getElementNamespace(&nslen);
|
||||
const char16_t* ns = inXml->getElementNamespace(&nslen);
|
||||
if (ns == NULL) {
|
||||
ns = (const uint16_t*)"\0\0";
|
||||
ns = (const char16_t*)"\0\0";
|
||||
nslen = 0;
|
||||
}
|
||||
const String8 nspace(String16(ns, nslen));
|
||||
@ -422,7 +422,7 @@ static String8 make_prefix(int depth)
|
||||
}
|
||||
|
||||
static String8 build_namespace(const Vector<namespace_entry>& namespaces,
|
||||
const uint16_t* ns)
|
||||
const char16_t* ns)
|
||||
{
|
||||
String8 str;
|
||||
if (ns != NULL) {
|
||||
@ -453,9 +453,9 @@ void printXMLBlock(ResXMLTree* block)
|
||||
int i;
|
||||
if (code == ResXMLTree::START_TAG) {
|
||||
size_t len;
|
||||
const uint16_t* ns16 = block->getElementNamespace(&len);
|
||||
const char16_t* ns16 = block->getElementNamespace(&len);
|
||||
String8 elemNs = build_namespace(namespaces, ns16);
|
||||
const uint16_t* com16 = block->getComment(&len);
|
||||
const char16_t* com16 = block->getComment(&len);
|
||||
if (com16) {
|
||||
printf("%s <!-- %s -->\n", prefix.string(), String8(com16).string());
|
||||
}
|
||||
@ -503,7 +503,7 @@ void printXMLBlock(ResXMLTree* block)
|
||||
} else if (code == ResXMLTree::START_NAMESPACE) {
|
||||
namespace_entry ns;
|
||||
size_t len;
|
||||
const uint16_t* prefix16 = block->getNamespacePrefix(&len);
|
||||
const char16_t* prefix16 = block->getNamespacePrefix(&len);
|
||||
if (prefix16) {
|
||||
ns.prefix = String8(prefix16);
|
||||
} else {
|
||||
@ -518,7 +518,7 @@ void printXMLBlock(ResXMLTree* block)
|
||||
depth--;
|
||||
const namespace_entry& ns = namespaces.top();
|
||||
size_t len;
|
||||
const uint16_t* prefix16 = block->getNamespacePrefix(&len);
|
||||
const char16_t* prefix16 = block->getNamespacePrefix(&len);
|
||||
String8 pr;
|
||||
if (prefix16) {
|
||||
pr = String8(prefix16);
|
||||
|
Reference in New Issue
Block a user