aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-05-16 17:58:48 -0700
committerIan Rogers <irogers@google.com>2014-05-16 18:00:21 -0700
commit5d6c98aae94b7be69007aa657f212f2bcd24709a (patch)
treed8b4e9dc69fd65d7dc9da4853088558c61735cda
parenteade9feb9464e7f86ff7a5853749a0885574588a (diff)
downloadlibnativehelper-5d6c98aae94b7be69007aa657f212f2bcd24709a.tar.gz
Make libnativehelper C++ library agnostic and remove libnativehelper_libc++.
Change-Id: Ib5510add3337992dc2a99affe671a01d39782237
-rw-r--r--Android.mk22
-rw-r--r--include/nativehelper/toStringArray.h22
-rw-r--r--toStringArray.cpp24
3 files changed, 21 insertions, 47 deletions
diff --git a/Android.mk b/Android.mk
index 53642d9..c79ad48 100644
--- a/Android.mk
+++ b/Android.mk
@@ -38,28 +38,6 @@ LOCAL_SHARED_LIBRARIES += libcutils libstlport libdl
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
include $(BUILD_SHARED_LIBRARY)
-# Don't build for unbundled branches
-ifeq (,$(TARGET_BUILD_APPS))
-#
-# Build for the target (device) using libc++.
-#
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
- $(local_src_files) \
- JniInvocation.cpp
-LOCAL_SHARED_LIBRARIES := liblog
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := libnativehelper_libc++
-LOCAL_CFLAGS := -Werror
-LOCAL_C_INCLUDES := libcore/include
-LOCAL_SHARED_LIBRARIES += libcutils libdl
-include external/libcxx/libcxx.mk
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-include $(BUILD_SHARED_LIBRARY)
-endif
-
-#
# NDK-only build for the target (device).
# - Relies only on NDK exposed functionality.
# - This doesn't include JniInvocation.
diff --git a/include/nativehelper/toStringArray.h b/include/nativehelper/toStringArray.h
index 55fae2c..9dc7a16 100644
--- a/include/nativehelper/toStringArray.h
+++ b/include/nativehelper/toStringArray.h
@@ -45,7 +45,27 @@ jobjectArray toStringArray(JNIEnv* env, Counter* counter, Getter* getter) {
return result;
}
-JNIEXPORT jobjectArray toStringArray(JNIEnv* env, const std::vector<std::string>& strings);
+struct VectorCounter {
+ const std::vector<std::string>& strings;
+ VectorCounter(const std::vector<std::string>& strings) : strings(strings) {}
+ size_t operator()() {
+ return strings.size();
+ }
+};
+struct VectorGetter {
+ const std::vector<std::string>& strings;
+ VectorGetter(const std::vector<std::string>& strings) : strings(strings) {}
+ const char* operator()(size_t i) {
+ return strings[i].c_str();
+ }
+};
+
+inline jobjectArray toStringArray(JNIEnv* env, const std::vector<std::string>& strings) {
+ VectorCounter counter(strings);
+ VectorGetter getter(strings);
+ return toStringArray<VectorCounter, VectorGetter>(env, &counter, &getter);
+}
+
JNIEXPORT jobjectArray toStringArray(JNIEnv* env, const char* const* strings);
#endif // TO_STRING_ARRAY_H_included
diff --git a/toStringArray.cpp b/toStringArray.cpp
index 414d43c..f2fa53c 100644
--- a/toStringArray.cpp
+++ b/toStringArray.cpp
@@ -17,34 +17,10 @@
#include "JniConstants.h"
#include "toStringArray.h"
-#include <string>
-#include <vector>
-
jobjectArray newStringArray(JNIEnv* env, size_t count) {
return env->NewObjectArray(count, JniConstants::stringClass, NULL);
}
-struct VectorCounter {
- const std::vector<std::string>& strings;
- VectorCounter(const std::vector<std::string>& strings) : strings(strings) {}
- size_t operator()() {
- return strings.size();
- }
-};
-struct VectorGetter {
- const std::vector<std::string>& strings;
- VectorGetter(const std::vector<std::string>& strings) : strings(strings) {}
- const char* operator()(size_t i) {
- return strings[i].c_str();
- }
-};
-
-jobjectArray toStringArray(JNIEnv* env, const std::vector<std::string>& strings) {
- VectorCounter counter(strings);
- VectorGetter getter(strings);
- return toStringArray<VectorCounter, VectorGetter>(env, &counter, &getter);
-}
-
struct ArrayCounter {
const char* const* strings;
ArrayCounter(const char* const* strings) : strings(strings) {}