diff options
author | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-05-04 13:26:26 +0200 |
---|---|---|
committer | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-05-04 13:26:26 +0200 |
commit | 6bb3118a6f170f376a08c3bc6ee7f50b6beeaf7f (patch) | |
tree | b971da549515e90112963016664a19fe450e218c | |
parent | bb851b75cc030c37b6a0ce0ce7580283c2c14fd5 (diff) | |
download | base-6bb3118a6f170f376a08c3bc6ee7f50b6beeaf7f.tar.gz |
frameworks/base: Compile fixes for ISO C++ 11
Fix build in ISO C++ 11 mode (where char16_t is defined and different
from uint16_t)
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r-- | include/media/ToneGenerator.h | 12 | ||||
-rw-r--r-- | include/utils/ResourceTypes.h | 20 | ||||
-rw-r--r-- | include/utils/Unicode.h | 2 | ||||
-rw-r--r-- | libs/utils/ResourceTypes.cpp | 26 |
4 files changed, 33 insertions, 27 deletions
diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h index 1ad1f26e108a..9811d0078bb0 100644 --- a/include/media/ToneGenerator.h +++ b/include/media/ToneGenerator.h @@ -199,12 +199,16 @@ private: NUM_REGIONS }; +#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__) +#define constexpr const +#endif + static const unsigned char sToneMappingTable[NUM_REGIONS-1][NUM_SUP_TONES]; - static const unsigned int TONEGEN_MAX_WAVES = 3; // Maximun number of sine waves in a tone segment - static const unsigned int TONEGEN_MAX_SEGMENTS = 12; // Maximun number of segments in a tone descriptor - static const unsigned int TONEGEN_INF = 0xFFFFFFFF; // Represents infinite time duration - static const float TONEGEN_GAIN = 0.9; // Default gain passed to WaveGenerator(). + static constexpr unsigned int TONEGEN_MAX_WAVES = 3; // Maximun number of sine waves in a tone segment + static constexpr unsigned int TONEGEN_MAX_SEGMENTS = 12; // Maximun number of segments in a tone descriptor + static constexpr unsigned int TONEGEN_INF = 0xFFFFFFFF; // Represents infinite time duration + static constexpr float TONEGEN_GAIN = 0.9; // Default gain passed to WaveGenerator(). // ToneDescriptor class contains all parameters needed to generate a tone: // - The array waveFreq[]: diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h index 612ff93463a7..16575788131a 100644 --- a/include/utils/ResourceTypes.h +++ b/include/utils/ResourceTypes.h @@ -642,25 +642,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: @@ -669,14 +669,14 @@ 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; 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; @@ -1982,7 +1982,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, diff --git a/include/utils/Unicode.h b/include/utils/Unicode.h index 92735337705d..66e56b0564c5 100644 --- a/include/utils/Unicode.h +++ b/include/utils/Unicode.h @@ -22,8 +22,10 @@ extern "C" { +#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__) typedef uint32_t char32_t; typedef uint16_t char16_t; +#endif // Standard string functions on char16_t strings. int strcmp16(const char16_t *, const char16_t *); diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp index d9bfa4a53eba..421c453111c4 100644 --- a/libs/utils/ResourceTypes.cpp +++ b/libs/utils/ResourceTypes.cpp @@ -82,9 +82,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; @@ -567,7 +567,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; @@ -786,7 +786,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; @@ -805,7 +805,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; @@ -828,7 +828,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); @@ -843,7 +843,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); @@ -861,7 +861,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; @@ -878,7 +878,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; @@ -907,7 +907,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); @@ -930,7 +930,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); @@ -962,7 +962,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)); @@ -2830,7 +2830,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, |