summaryrefslogtreecommitdiffstats
path: root/tools/aapt
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2014-11-03 23:38:42 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-11-03 23:38:43 +0000
commit668f0a356cba44c22d8ca0c9f4711613885d46a9 (patch)
tree2a761d729c706abe8c4fca98e89d818e961a5168 /tools/aapt
parent3c7efdc00506e6561ca08933f0b2acf5e3f16b02 (diff)
parent4bf58108d442b37ab4adf5ce3a4ecd63472ce254 (diff)
downloadframeworks_base-668f0a356cba44c22d8ca0c9f4711613885d46a9.zip
frameworks_base-668f0a356cba44c22d8ca0c9f4711613885d46a9.tar.gz
frameworks_base-668f0a356cba44c22d8ca0c9f4711613885d46a9.tar.bz2
Merge "Fix issues that will be present in C++11" into lmp-mr1-dev
Diffstat (limited to 'tools/aapt')
-rw-r--r--tools/aapt/AaptXml.cpp4
-rw-r--r--tools/aapt/Android.mk56
-rw-r--r--tools/aapt/CacheUpdater.h4
-rw-r--r--tools/aapt/Main.cpp4
-rw-r--r--tools/aapt/Resource.cpp10
-rw-r--r--tools/aapt/ResourceTable.cpp10
-rw-r--r--tools/aapt/StringPool.cpp16
-rw-r--r--tools/aapt/StringPool.h5
-rw-r--r--tools/aapt/XMLNode.cpp18
9 files changed, 64 insertions, 63 deletions
diff --git a/tools/aapt/AaptXml.cpp b/tools/aapt/AaptXml.cpp
index 708e405..b04a55d 100644
--- a/tools/aapt/AaptXml.cpp
+++ b/tools/aapt/AaptXml.cpp
@@ -41,7 +41,7 @@ static String8 getStringAttributeAtIndex(const ResXMLTree& tree, ssize_t attrInd
}
size_t len;
- const uint16_t* str = tree.getAttributeStringValue(attrIndex, &len);
+ const char16_t* str = tree.getAttributeStringValue(attrIndex, &len);
return str ? String8(str, len) : String8();
}
@@ -103,7 +103,7 @@ String8 getResolvedAttribute(const ResTable& resTable, const ResXMLTree& tree,
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);
diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk
index 2cbabe1..bc9c1f7 100644
--- a/tools/aapt/Android.mk
+++ b/tools/aapt/Android.mk
@@ -33,20 +33,20 @@ aaptSources := \
Command.cpp \
CrunchCache.cpp \
FileFinder.cpp \
+ Images.cpp \
Package.cpp \
- StringPool.cpp \
- XMLNode.cpp \
+ pseudolocalize.cpp \
+ qsort_r_compat.c \
+ Resource.cpp \
ResourceFilter.cpp \
ResourceIdCache.cpp \
ResourceTable.cpp \
- Images.cpp \
- Resource.cpp \
- pseudolocalize.cpp \
SourcePos.cpp \
+ StringPool.cpp \
WorkQueue.cpp \
+ XMLNode.cpp \
ZipEntry.cpp \
- ZipFile.cpp \
- qsort_r_compat.c
+ ZipFile.cpp
aaptTests := \
tests/AaptConfig_test.cpp \
@@ -88,16 +88,13 @@ endif
include $(CLEAR_VARS)
LOCAL_MODULE := libaapt
-
-LOCAL_SRC_FILES := $(aaptSources)
-LOCAL_C_INCLUDES += $(aaptCIncludes)
-
-LOCAL_CFLAGS += -Wno-format-y2k
-LOCAL_CFLAGS += -DSTATIC_ANDROIDFW_FOR_TOOLS
-LOCAL_CFLAGS += $(aaptCFlags)
+LOCAL_CFLAGS += -Wno-format-y2k -DSTATIC_ANDROIDFW_FOR_TOOLS $(aaptCFlags)
+LOCAL_CPPFLAGS += $(aaptCppFlags)
ifeq (darwin,$(HOST_OS))
LOCAL_CFLAGS += -D_DARWIN_UNLIMITED_STREAMS
endif
+LOCAL_C_INCLUDES += $(aaptCIncludes)
+LOCAL_SRC_FILES := $(aaptSources)
include $(BUILD_HOST_STATIC_LIBRARY)
@@ -108,15 +105,11 @@ include $(BUILD_HOST_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := aapt
-
-LOCAL_SRC_FILES := $(aaptMain)
-
-LOCAL_STATIC_LIBRARIES += \
- libaapt \
- $(aaptHostStaticLibs)
-
-LOCAL_LDLIBS += $(aaptHostLdLibs)
LOCAL_CFLAGS += $(aaptCFlags)
+LOCAL_CPPFLAGS += $(aaptCppFlags)
+LOCAL_LDLIBS += $(aaptHostLdLibs)
+LOCAL_SRC_FILES := $(aaptMain)
+LOCAL_STATIC_LIBRARIES += libaapt $(aaptHostStaticLibs)
include $(BUILD_HOST_EXECUTABLE)
@@ -127,16 +120,12 @@ include $(BUILD_HOST_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := libaapt_tests
-
+LOCAL_CFLAGS += $(aaptCFlags)
+LOCAL_CPPFLAGS += $(aaptCppFlags)
+LOCAL_LDLIBS += $(aaptHostLdLibs)
LOCAL_SRC_FILES += $(aaptTests)
LOCAL_C_INCLUDES += $(LOCAL_PATH)
-
-LOCAL_STATIC_LIBRARIES += \
- libaapt \
- $(aaptHostStaticLibs)
-
-LOCAL_LDLIBS += $(aaptHostLdLibs)
-LOCAL_CFLAGS += $(aaptCFlags)
+LOCAL_STATIC_LIBRARIES += libaapt $(aaptHostStaticLibs)
include $(BUILD_HOST_NATIVE_TEST)
@@ -148,13 +137,12 @@ ifneq ($(SDK_ONLY),true)
include $(CLEAR_VARS)
LOCAL_MODULE := aapt
-
+LOCAL_CFLAGS += $(aaptCFlags)
LOCAL_SRC_FILES := $(aaptSources) $(aaptMain)
LOCAL_C_INCLUDES += \
$(aaptCIncludes) \
bionic \
external/stlport/stlport
-
LOCAL_SHARED_LIBRARIES := \
libandroidfw \
libutils \
@@ -162,14 +150,10 @@ LOCAL_SHARED_LIBRARIES := \
libpng \
liblog \
libz
-
LOCAL_STATIC_LIBRARIES := \
libstlport_static \
libexpat_static
-LOCAL_CFLAGS += $(aaptCFlags)
-LOCAL_CPPFLAGS += -Wno-non-virtual-dtor
-
include $(BUILD_EXECUTABLE)
endif # Not SDK_ONLY
diff --git a/tools/aapt/CacheUpdater.h b/tools/aapt/CacheUpdater.h
index efb2453..fade53a 100644
--- a/tools/aapt/CacheUpdater.h
+++ b/tools/aapt/CacheUpdater.h
@@ -30,6 +30,8 @@ using namespace android;
*/
class CacheUpdater {
public:
+ virtual ~CacheUpdater() {}
+
// Make sure all the directories along this path exist
virtual void ensureDirectoriesExist(String8 path) = 0;
@@ -107,4 +109,4 @@ private:
Bundle* bundle;
};
-#endif // CACHE_UPDATER_H \ No newline at end of file
+#endif // CACHE_UPDATER_H
diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp
index 2857b59..18b8e1e 100644
--- a/tools/aapt/Main.cpp
+++ b/tools/aapt/Main.cpp
@@ -11,9 +11,9 @@
#include <utils/List.h>
#include <utils/Errors.h>
-#include <stdlib.h>
+#include <cstdlib>
#include <getopt.h>
-#include <assert.h>
+#include <cassert>
using namespace android;
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index a4c9dab..b9bd03a 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -261,7 +261,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);
}
@@ -450,7 +450,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();
@@ -503,7 +503,7 @@ static int validateAttr(const String8& path, const ResTable& table,
}
if (validChars) {
for (size_t i=0; i<len; i++) {
- uint16_t c = str[i];
+ char16_t c = str[i];
const char* p = validChars;
bool okay = false;
while (*p) {
@@ -1710,7 +1710,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
}
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(),
@@ -1753,7 +1753,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
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());
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 4587a4b..0f94f85 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -399,7 +399,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) {
@@ -1325,7 +1325,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) {
@@ -1441,14 +1441,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;
}
diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp
index 06769e4..2727b3d 100644
--- a/tools/aapt/StringPool.cpp
+++ b/tools/aapt/StringPool.cpp
@@ -21,7 +21,8 @@
#define NOISY(x) //x
-void strcpy16_htod(uint16_t* dst, const uint16_t* src)
+#if __cplusplus >= 201103L
+void strcpy16_htod(char16_t* dst, const char16_t* src)
{
while (*src) {
char16_t s = htods(*src);
@@ -30,6 +31,17 @@ void strcpy16_htod(uint16_t* dst, const uint16_t* src)
}
*dst = 0;
}
+#endif
+
+void strcpy16_htod(uint16_t* dst, const char16_t* src)
+{
+ while (*src) {
+ uint16_t s = htods(static_cast<uint16_t>(*src));
+ *dst++ = s;
+ src++;
+ }
+ *dst = 0;
+}
void printStringPool(const ResStringPool* pool)
{
@@ -416,7 +428,7 @@ status_t StringPool::writeStringBlock(const sp<AaptFile>& pool)
return NO_MEMORY;
}
- const size_t charSize = mUTF8 ? sizeof(uint8_t) : sizeof(char16_t);
+ const size_t charSize = mUTF8 ? sizeof(uint8_t) : sizeof(uint16_t);
size_t strPos = 0;
for (i=0; i<STRINGS; i++) {
diff --git a/tools/aapt/StringPool.h b/tools/aapt/StringPool.h
index 1b3abfd..a9c7bec 100644
--- a/tools/aapt/StringPool.h
+++ b/tools/aapt/StringPool.h
@@ -26,7 +26,10 @@ using namespace android;
#define PRINT_STRING_METRICS 0
-void strcpy16_htod(uint16_t* dst, const uint16_t* src);
+#if __cplusplus >= 201103L
+void strcpy16_htod(char16_t* dst, const char16_t* src);
+#endif
+void strcpy16_htod(uint16_t* dst, const char16_t* src);
void printStringPool(const ResStringPool* pool);
diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp
index 51a4154..899fb63 100644
--- a/tools/aapt/XMLNode.cpp
+++ b/tools/aapt/XMLNode.cpp
@@ -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);