aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2016-06-10 14:24:36 -0700
committerChih-Hung Hsieh <chh@google.com>2016-06-21 16:13:54 -0700
commit83c7169a0f2f8a3bd49d0855ae3d265243068972 (patch)
treeb8f8a9864e9f03e59e197627ad29f7618ae33fea /include
parent4edb6bc274fc2bdf6b9aac7e558dd16856079e28 (diff)
downloadplatform_libnativehelper-83c7169a0f2f8a3bd49d0855ae3d265243068972.tar.gz
platform_libnativehelper-83c7169a0f2f8a3bd49d0855ae3d265243068972.tar.bz2
platform_libnativehelper-83c7169a0f2f8a3bd49d0855ae3d265243068972.zip
Fix misc-macro-parentheses warnings in libnativehelper.
Replace T* and T& with POINTER_TYPE(T) and REFERENCE_TYPE(T) in macros to avoid wrong clang-tidy warnings. Use NOLINT to suppress warnings in POINTER_TYPE(T) and REFERENCE_TYPE(T). Bug: 28705665 Change-Id: I4dc985b9050b47af020f0f3188a64a891ff88ac8
Diffstat (limited to 'include')
-rw-r--r--include/nativehelper/ScopedPrimitiveArray.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/include/nativehelper/ScopedPrimitiveArray.h b/include/nativehelper/ScopedPrimitiveArray.h
index b681b99..46f1786 100644
--- a/include/nativehelper/ScopedPrimitiveArray.h
+++ b/include/nativehelper/ScopedPrimitiveArray.h
@@ -19,6 +19,18 @@
#include "JNIHelp.h"
+#ifdef POINTER_TYPE
+#error POINTER_TYPE is defined.
+#else
+#define POINTER_TYPE(T) T* /* NOLINT */
+#endif
+
+#ifdef REFERENCE_TYPE
+#error REFERENCE_TYPE is defined.
+#else
+#define REFERENCE_TYPE(T) T& /* NOLINT */
+#endif
+
// ScopedBooleanArrayRO, ScopedByteArrayRO, ScopedCharArrayRO, ScopedDoubleArrayRO,
// ScopedFloatArrayRO, ScopedIntArrayRO, ScopedLongArrayRO, and ScopedShortArrayRO provide
// convenient read-only access to Java arrays from JNI code. This is cheaper than read-write
@@ -62,7 +74,7 @@
static const jsize buffer_size = 1024; \
JNIEnv* const mEnv; \
PRIMITIVE_TYPE ## Array mJavaArray; \
- PRIMITIVE_TYPE* mRawArray; \
+ POINTER_TYPE(PRIMITIVE_TYPE) mRawArray; \
jsize mSize; \
PRIMITIVE_TYPE mBuffer[buffer_size]; \
DISALLOW_COPY_AND_ASSIGN(Scoped ## NAME ## ArrayRO); \
@@ -108,13 +120,13 @@ INSTANTIATE_SCOPED_PRIMITIVE_ARRAY_RO(jshort, Short);
const PRIMITIVE_TYPE* get() const { return mRawArray; } \
PRIMITIVE_TYPE ## Array getJavaArray() const { return mJavaArray; } \
const PRIMITIVE_TYPE& operator[](size_t n) const { return mRawArray[n]; } \
- PRIMITIVE_TYPE* get() { return mRawArray; } \
- PRIMITIVE_TYPE& operator[](size_t n) { return mRawArray[n]; } \
+ POINTER_TYPE(PRIMITIVE_TYPE) get() { return mRawArray; } \
+ REFERENCE_TYPE(PRIMITIVE_TYPE) operator[](size_t n) { return mRawArray[n]; } \
size_t size() const { return mEnv->GetArrayLength(mJavaArray); } \
private: \
JNIEnv* const mEnv; \
PRIMITIVE_TYPE ## Array mJavaArray; \
- PRIMITIVE_TYPE* mRawArray; \
+ POINTER_TYPE(PRIMITIVE_TYPE) mRawArray; \
DISALLOW_COPY_AND_ASSIGN(Scoped ## NAME ## ArrayRW); \
}
@@ -128,5 +140,7 @@ INSTANTIATE_SCOPED_PRIMITIVE_ARRAY_RW(jlong, Long);
INSTANTIATE_SCOPED_PRIMITIVE_ARRAY_RW(jshort, Short);
#undef INSTANTIATE_SCOPED_PRIMITIVE_ARRAY_RW
+#undef POINTER_TYPE
+#undef REFERENCE_TYPE
#endif // SCOPED_PRIMITIVE_ARRAY_H_included