author | Jim Chen <nchen@mozilla.com> |
Mon, 27 Jun 2016 14:49:55 -0400 | |
changeset 302795 | 5c6ee7ceb0a94631fb2eab71a6190b358e52c6f3 |
parent 302794 | 6f2a56ca83e77b8fa88b7f0c5104d5b02f329762 |
child 302796 | 87bbd3f58b4b153facdd1a2995105ae28cfbcd21 |
push id | 30376 |
push user | cbook@mozilla.com |
push date | Tue, 28 Jun 2016 14:09:36 +0000 |
treeherder | mozilla-central@e45890951ce7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | me |
bugs | 1277624 |
milestone | 50.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
widget/android/jni/Accessors.h | file | annotate | diff | comparison | revisions | |
widget/android/jni/Natives.h | file | annotate | diff | comparison | revisions |
--- a/widget/android/jni/Accessors.h +++ b/widget/android/jni/Accessors.h @@ -6,17 +6,17 @@ #include "mozilla/jni/Refs.h" #include "mozilla/jni/Types.h" #include "mozilla/jni/Utils.h" #include "AndroidBridge.h" namespace mozilla { namespace jni { -namespace { +namespace detail { // Helper class to convert an arbitrary type to a jvalue, e.g. Value(123).val. struct Value { Value(jboolean z) { val.z = z; } Value(jbyte b) { val.b = b; } Value(jchar c) { val.c = c; } Value(jshort s) { val.s = s; } @@ -24,18 +24,19 @@ struct Value Value(jlong j) { val.j = j; } Value(jfloat f) { val.f = f; } Value(jdouble d) { val.d = d; } Value(jobject l) { val.l = l; } jvalue val; }; -} +} // namespace detail +using namespace detail; // Base class for Method<>, Field<>, and Constructor<>. class Accessor { static void GetNsresult(JNIEnv* env, nsresult* rv) { if (env->ExceptionCheck()) { #ifdef DEBUG
--- a/widget/android/jni/Natives.h +++ b/widget/android/jni/Natives.h @@ -66,19 +66,19 @@ namespace jni { * instance, mozilla::MakeUnique<MyClass>()); * * // "instance" owns the newly created C++ object, so the C++ * // object is destroyed as soon as instance.dispose() is called. * } * }; */ -namespace { +namespace detail { -uintptr_t CheckNativeHandle(JNIEnv* env, uintptr_t handle) +inline uintptr_t CheckNativeHandle(JNIEnv* env, uintptr_t handle) { if (!handle) { if (!env->ExceptionCheck()) { ThrowException(env, "java/lang/NullPointerException", "Null native pointer"); } return 0; } @@ -168,17 +168,19 @@ struct NativePtr<Impl, /* UseWeakPtr = * if (ptr) { SetNativeHandle(instance.Env(), instance.Get(), 0); MOZ_CATCH_JNI_EXCEPTION(instance.Env()); delete ptr; } } }; -} // namespace +} // namespace detail + +using namespace detail; /** * For C++ classes whose native methods all return void, they can choose to * have the native calls go through a proxy by inheriting from * mozilla::jni::UsesNativeCallProxy, and overriding the OnNativeCall member. * Subsequently, every native call is automatically wrapped in a functor * object, and the object is passed to OnNativeCall. The OnNativeCall * implementation can choose to invoke the call, save it, dispatch it to a @@ -217,20 +219,16 @@ struct UsesNativeCallProxy } }; namespace detail { template<class Traits, class Impl, class Args, bool IsStatic, bool IsVoid> class NativeStubImpl; -} - -namespace { - // ProxyArg is used to handle JNI ref arguments for proxies. Because a proxied // call may happen outside of the original JNI native call, we must save all // JNI ref arguments as global refs to avoid the arguments going out of scope. template<typename T> struct ProxyArg { static_assert(mozilla::IsPod<T>::value, "T must be primitive type"); @@ -412,17 +410,17 @@ typename mozilla::EnableIf< Dispatch(ProxyNativeCall<Impl, O, S, V, A...>&& call) { Impl::OnNativeCall(mozilla::Move(call)); } template<typename T> void Dispatch(const T&) {} -} // namespace +} // namespace detail template<class Cls, class Impl> class NativeImpl; namespace detail { // Wrapper methods that convert arguments from the JNI types to the native // types, e.g. from jobject to jni::Object::Ref. For instance methods, the // wrapper methods also convert calls to calls on objects.