clang complains that it's unable to instantiate this template because
the functions being passed as arguments are MOZ_JNICALL, while the
actual parameter to the function has no such attribute. Adding the
attribute makes everything line up.
clang complains about specializations of NativeStubImpl not being able
to see the private constructor of ProxyNativeCall. While
ProxyNativeCall includes a friend declaration for NativeStubImpl, it's
not obvious *which* NativeStubImpl is being friended, as NativeStubImpl
hasn't been forward declared and exists in a completely separate
namespace. Forward declaring NativeStubImpl and adjusting the friend
declaration makes everything more correct.
Even though a class may not be multi-threaded, its object references can
still be passed to different threads. As long as the references are not
accessed, we should allow it, and therefore GlobalRef should use
GetEnvForThread for ref/unref, instead of using FindEnv, which can
trigger assertions on non-main threads.
WindowEvent is not specific to GeckoViewSupport, and classes other than
GeckoViewSupport use it, so this patch moves it to outside of
GeckoViewSupport.
Improve the performance of JNI calls by making JNI calls require a
Context object. LocalRef inherits from Context and can make calls
directly. Non-local Ref classes will generate a Context object when
making a call. The patch also makes the template design cleaner in
several cases.
Implement the PrefsHelper native methods. The previous browser.js
implementation supported "pseudo-prefs" that did not exist as actual
prefs, but was accessible through PrefsHelper. In order to accommodate
these pseudo-prefs, we send observer notifications in order to
communicate with browser.js about prefs that we don't support.
This patch adds specializations of jni::Ref for primitive arrays like
IntArray and FloatArray, so that the arrays can be accessed through the
GetElement, GetElements, and Length members.
When we have a Java exception in native code, the Java stack in the
exception will not be very useful because the top frame is the native
entry point. In this case, the native stack is more useful. However,
currently we don't get a good native stack in this situation because we
go through Java when handling the exception, and the native stack we get
will have a lot of unknown frames inside libdvm or libart. This patch
makes us stay in native code when handling an uncaught exception from
native code, so that we get a good native stack.
GLController instances are associated with a particular nsWindow, rather
than a particular View. Therefore, we need to let GeckoView manage
GLController instances, as part of GeckoView's handling of saving and
restoring states.
GeckoEvent.KEY_EVENT and GeckoEvent.IME_EVENT used to count as UI events
for the hang monitor. We should count the new native calls as native
events too through this patch.
It's helpful to have a static DisposeNative when disposing of instances
that are still associated with a native object through an null weak
pointer. In that case, we can't call instance methods because the weak
pointer is null, but we can still call static methods.
This patch adds a specialization for jni::Ref<jni::ObjectArray>, which
includes members for getting the length of the array and accessing
array elements.
This patch adds a specialization for jni::Ref<jni::ObjectArray>, which
includes members for getting the length of the array and accessing
array elements.
The patch removes 455 occurrences of FAIL_ON_WARNINGS from moz.build files, and
adds 78 instances of ALLOW_COMPILER_WARNINGS. About half of those 78 are in
code we control and which should be removable with a little effort.
--HG--
extra : rebase_source : 82e3387abfbd5f1471e953961d301d3d97ed2973
If a C++ class implements native calls that all return void, it can
choose to have those calls go through a custom proxy function by
inheriting from mozilla::jni::UsesNativeCallProxy and override the
ProxyNativeCall member.
ProxyNativeCall accepts a rvalue reference to a
functor object specific to each call, and can alter the calling
environment (e.g. dispatch the call to another thread) before issuing
the actual native call through the functor's operator().
Any JNI refs contained in the call are automatically turned into global
refs so that the call can continue to work outside of the original JNI
call.
Native call proxy will be used to implement automatic dispatching of
native calls from the main thread to run on the Gecko thread.
This patch fixes a compile error when using WeakPtr, where Impl* was
expected but SupportsWeakPtr<Impl>* was given.
This patch also fixes a compile error when using the DisposeNative
implementation provided by the autogenerated Natives class. e.g.,
> struct Foo : Bar::Natives<Foo> {
> using Bar::Natives<Foo>::DisposeNative;
> };
This uses a default implementation of DisposeNative instead of a custom
implementation, and resulted in a compile error that this patch fixes.
The mangled name of a NativeStubImpl instantiation is longer than
necessary because of the ReturnType arg. This patch turns it into a bool
parameter. It also reorders the parameters for cleanness.
Add more constructors in LocalRef and GlobalRef to accommodate use cases
where a JNIEnv is already available for performance reasons. Also add
more null-checks when creating references for performance reasons.
clang doesn't like it when we declare things as a struct in one place
and a class in another. This change makes all the current usages
consistent and clang happy.
Add a direct ownership model where the Java object owns the
corresponding C++ object directly, in addition to the WeakPtr model
where the Java object owns a WeakPtr to the C++ object. The WeakPtr
model is chosen when the implementing C++ class inherits from
SupportsWeakPtr. Otherwise, the direct ownership model is chosen. Under
the direct ownership model, a UniquePtr object must be used to attach
the containing C++ object to a Java object, to ensure ownership is
passed on to the Java object.
This patch adds:
* Conversion operator from String::Param to String::LocalRef.
* More overloads of the jni::ThrowException function.
* name members to built-in types like jni::Object, jni::String, etc.
This allows using jni::Accessors::EnsureClassRef on built-in types
to get built-in class refs (e.g. jclass for java/lang/String).
* Ability to implicitly convert LocalRef<Cls> to LocalRef<Object>
* Fixes for bugs in LocalRef/GlobalRef where new refs are not created.
* Fixes for inaccurate uses of mozilla::Forward in favor of mozilla::Move
We use Ref::From() inside TypeAdapter<Ref>::ToNative to convert a raw JNI
ref argument to a Ref argument for the C++ function. However, that
generates a compile error, unless we make TypeAdapter<Ref> a friend of
Ref, because we intentionally made Ref's copy constructor private and
returning from TypeAdapter<Ref>::ToNative requires the copy constructor.
Introduce a JNIObject class that serves as a base class for classes
that wish to use per-instance native methods. JNIObject includes a long
native pointer field that the C++ code accesses to associate the Java
object instance with a C++ object instance.