OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "webrtc/api/java/jni/jni_helpers.h" | 10 #include "webrtc/api/java/jni/jni_helpers.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 CHECK_EXCEPTION(jni) << "error during GetIntField"; | 195 CHECK_EXCEPTION(jni) << "error during GetIntField"; |
196 return i; | 196 return i; |
197 } | 197 } |
198 | 198 |
199 bool GetBooleanField(JNIEnv* jni, jobject object, jfieldID id) { | 199 bool GetBooleanField(JNIEnv* jni, jobject object, jfieldID id) { |
200 jboolean b = jni->GetBooleanField(object, id); | 200 jboolean b = jni->GetBooleanField(object, id); |
201 CHECK_EXCEPTION(jni) << "error during GetBooleanField"; | 201 CHECK_EXCEPTION(jni) << "error during GetBooleanField"; |
202 return b; | 202 return b; |
203 } | 203 } |
204 | 204 |
205 // Java references to "null" can only be distinguished as such in C++ by | |
206 // creating a local reference, so this helper wraps that logic. | |
207 bool IsNull(JNIEnv* jni, jobject obj) { | 205 bool IsNull(JNIEnv* jni, jobject obj) { |
208 ScopedLocalRefFrame local_ref_frame(jni); | 206 return jni->IsSameObject(obj, nullptr); |
209 return jni->NewLocalRef(obj) == NULL; | |
210 } | 207 } |
211 | 208 |
212 // Given a UTF-8 encoded |native| string return a new (UTF-16) jstring. | 209 // Given a UTF-8 encoded |native| string return a new (UTF-16) jstring. |
213 jstring JavaStringFromStdString(JNIEnv* jni, const std::string& native) { | 210 jstring JavaStringFromStdString(JNIEnv* jni, const std::string& native) { |
214 jstring jstr = jni->NewStringUTF(native.c_str()); | 211 jstring jstr = jni->NewStringUTF(native.c_str()); |
215 CHECK_EXCEPTION(jni) << "error during NewStringUTF"; | 212 CHECK_EXCEPTION(jni) << "error during NewStringUTF"; |
216 return jstr; | 213 return jstr; |
217 } | 214 } |
218 | 215 |
219 // Given a (UTF-16) jstring return a new UTF-8 native string. | 216 // Given a (UTF-16) jstring return a new UTF-8 native string. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 // callbacks (i.e. entry points that don't originate in a Java callstack | 266 // callbacks (i.e. entry points that don't originate in a Java callstack |
270 // through a "native" method call). | 267 // through a "native" method call). |
271 ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) { | 268 ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) { |
272 RTC_CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame"; | 269 RTC_CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame"; |
273 } | 270 } |
274 ScopedLocalRefFrame::~ScopedLocalRefFrame() { | 271 ScopedLocalRefFrame::~ScopedLocalRefFrame() { |
275 jni_->PopLocalFrame(NULL); | 272 jni_->PopLocalFrame(NULL); |
276 } | 273 } |
277 | 274 |
278 } // namespace webrtc_jni | 275 } // namespace webrtc_jni |
OLD | NEW |