OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/android/jni_array.h" | 5 #include "base/android/jni_array.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 DCHECK(out); | 178 DCHECK(out); |
179 size_t len = SafeGetArrayLength(env, int_array); | 179 size_t len = SafeGetArrayLength(env, int_array); |
180 out->resize(len); | 180 out->resize(len); |
181 if (!len) | 181 if (!len) |
182 return; | 182 return; |
183 // TODO(jdduke): Use |out->data()| for pointer access after switch to libc++, | 183 // TODO(jdduke): Use |out->data()| for pointer access after switch to libc++, |
184 // both here and in the other conversion routines. See crbug.com/427718. | 184 // both here and in the other conversion routines. See crbug.com/427718. |
185 env->GetIntArrayRegion(int_array, 0, len, &(*out)[0]); | 185 env->GetIntArrayRegion(int_array, 0, len, &(*out)[0]); |
186 } | 186 } |
187 | 187 |
188 void JavaLongArrayToInt64Vector(JNIEnv* env, | |
189 jlongArray long_array, | |
190 std::vector<int64>* out) { | |
191 DCHECK(out); | |
192 size_t len = SafeGetArrayLength(env, long_array); | |
193 out->resize(len); | |
194 if (!len) | |
195 return; | |
196 env->GetLongArrayRegion(long_array, 0, len, &(*out)[0]); | |
DmitrySkiba
2015/08/25 14:31:44
Hmm, this should produce a warning because GetLong
fgorski
2015/08/25 18:37:55
Good point, I am testing the updated version now.
| |
197 } | |
198 | |
188 void JavaLongArrayToLongVector(JNIEnv* env, | 199 void JavaLongArrayToLongVector(JNIEnv* env, |
189 jlongArray long_array, | 200 jlongArray long_array, |
190 std::vector<jlong>* out) { | 201 std::vector<jlong>* out) { |
191 DCHECK(out); | 202 DCHECK(out); |
192 size_t len = SafeGetArrayLength(env, long_array); | 203 size_t len = SafeGetArrayLength(env, long_array); |
193 out->resize(len); | 204 out->resize(len); |
194 if (!len) | 205 if (!len) |
195 return; | 206 return; |
196 env->GetLongArrayRegion(long_array, 0, len, &(*out)[0]); | 207 env->GetLongArrayRegion(long_array, 0, len, &(*out)[0]); |
197 } | 208 } |
(...skipping 22 matching lines...) Expand all Loading... | |
220 env->GetObjectArrayElement(array, i))); | 231 env->GetObjectArrayElement(array, i))); |
221 jsize bytes_len = env->GetArrayLength(bytes_array.obj()); | 232 jsize bytes_len = env->GetArrayLength(bytes_array.obj()); |
222 jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), NULL); | 233 jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), NULL); |
223 (*out)[i].assign(reinterpret_cast<const char*>(bytes), bytes_len); | 234 (*out)[i].assign(reinterpret_cast<const char*>(bytes), bytes_len); |
224 env->ReleaseByteArrayElements(bytes_array.obj(), bytes, JNI_ABORT); | 235 env->ReleaseByteArrayElements(bytes_array.obj(), bytes, JNI_ABORT); |
225 } | 236 } |
226 } | 237 } |
227 | 238 |
228 } // namespace android | 239 } // namespace android |
229 } // namespace base | 240 } // namespace base |
OLD | NEW |