Commit Graph

35 Commits

Author SHA1 Message Date
Jim Chen
296a0a08cc Bug 1238761 - Add specializations of jni::Ref for primitive arrays; r=snorp
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.
2016-01-15 13:05:44 -05:00
Jim Chen
dbe0fdff66 Bug 1235475 - Crash at the exception source when an exception is in native code; r=snorp
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.
2015-12-30 18:36:41 -05:00
Jim Chen
0ab8e63862 Bug 1227706 - Implement nsWindow::GLControllerSupport; r=snorp
This patch adds native method implementations in GLControllerSupport to
manage compositor creation/pause/resume.
2015-12-23 22:03:34 -05:00
Jim Chen
b2961d2eee Bug 1227706 - Let GeckoView manage GLController instances; r=snorp
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.
2015-12-23 22:03:34 -05:00
Jim Chen
56c1df6cc9 Bug 1227731 - Add ability to redirect proxied native calls; r=snorp
This patch adds a way to set the target of a proxied native call, so the
call goes to another C++ function / class member than the original
target.
2015-12-23 22:03:34 -05:00
Birunthan Mohanathas
94998cf5fe Bug 1219392 - Capitalize mozilla::unused to avoid conflicts. r=froydnj 2015-11-02 07:53:26 +02:00
Jim Chen
3f3894a30c Bug 1211704 - Count key and IME events as UI events; r=esawin
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.
2015-10-22 17:45:47 -04:00
Jim Chen
491ddf6097 Bug 1215139 - Make NativeImpl::DisposeNative a static member; r=snorp
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.
2015-10-22 17:45:46 -04:00
Jim Chen
4c5c5c26db Bug 1207642 - Work around Dalvik bug by realigning stack on JNI entry. r=snorp
Use the force_align_arg_pointer attribute to force realigning stack at JNI entry points.
2015-10-21 08:27:00 -04:00
Jim Chen
57d4591467 Bug 1200343 - Add JNI wrapper for object arrays; r=snorp
This patch adds a specialization for jni::Ref<jni::ObjectArray>, which
includes members for getting the length of the array and accessing
array elements.
2015-09-28 12:07:09 -04:00
Wes Kocher
5ad8b759ce Backed out 4 changesets (bug 1200343) for android talos failures
Backed out changeset 67dc42cbf02b (bug 1200343)
Backed out changeset b077acafcebb (bug 1200343)
Backed out changeset e115ca114601 (bug 1200343)
Backed out changeset 905e1fb54fd4 (bug 1200343)
2015-09-25 13:21:58 -07:00
Jim Chen
3c7836a62a Bug 1200343 - Add JNI wrapper for object arrays; r=snorp
This patch adds a specialization for jni::Ref<jni::ObjectArray>, which
includes members for getting the length of the array and accessing
array elements.
2015-09-25 15:03:34 -04:00
Chris Peterson
dd2fcb9b7d Bug 1207030 - Enable -Wshadow flag in more directories that have no -Wshadow warnings. r=glandium 2015-09-22 21:39:03 -07:00
Nicholas Nethercote
69d088e45f Bug 1198334 (part 1) - Replace the opt-in FAIL_ON_WARNINGS with the opt-out ALLOW_COMPILER_WARNINGS. r=glandium.
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.
2015-08-27 20:44:53 -07:00
Jim Chen
dc909a59fe Bug 1192043 - Add support for proxying native calls; r=snorp
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.
2015-08-25 14:52:16 -04:00
Jim Chen
32507efd58 Bug 1192043 - Fix compile errors in Natives.h; r=snorp
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.
2015-08-25 14:52:16 -04:00
Jim Chen
f28b8ba447 Bug 1192043 - Clean up NativeStubImpl template parameters; r=snorp
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.
2015-08-25 14:52:16 -04:00
Jim Chen
d5598ed53a Bug 1192043 - Add more JNIEnv support and null-check refs in JNI ref classs; r=snorp
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.
2015-08-25 14:52:16 -04:00
Nathan Froyd
dd9d75a87e Bug 1194806 - part 5 - mark function pointer-to-members with JNICALL appropriately; r=snorp,jchen 2015-08-14 23:03:45 -04:00
Nathan Froyd
8804cb6f68 Bug 1194806 - part 4 - use |typename| to refer to trait class typedefs, not |class|; r=jchen 2015-08-14 22:34:16 -04:00
Nathan Froyd
be953f88b7 Bug 1194806 - part 1 - consistently declare mozilla::jni::detail::TypeAdaptor as a struct; r=jchen
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.
2015-08-14 21:59:27 -04:00
Jim Chen
25353fa7f4 Bug 1192077 - Convert AndroidBridge JNIEnv calls; r=esawin 2015-08-13 00:53:39 -04:00
Jim Chen
2fb5d313bd Bug 1192077 - Move AndroidBridge JNIEnv calls to jni/Utils; r=esawin
Calls like GetJNIForThread should now belong in jni/Utils. Moving the
calls also reduce clutter in AndroidBridge.
2015-08-13 00:53:39 -04:00
Jim Chen
d201a85a4a Bug 1187552 - Support direct ownership of C++ objects by Java objects; r=snorp
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.
2015-08-04 17:47:28 -04:00
Jim Chen
412ca11ada Bug 1187088 - Use UNIFIED_SOURCES in widget/android; r=snorp
Fix some compiling errors in unified mode due to header dependency
issues.
2015-08-04 17:47:28 -04:00
Jim Chen
1a0434f7e6 Bug 1186467 - Add some JNI utilities for convenience; r=snorp
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
2015-08-04 17:47:28 -04:00
Jim Chen
3698d9113b Bug 1186530 - Fix compile error when using native methods with ref parameters; r=snorp
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.
2015-07-29 15:11:15 -04:00
Jim Chen
527dd49d80 Bug 1186530 - Add support for instance native pointers; r=snorp
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.
2015-07-29 15:11:15 -04:00
Jim Chen
78c1bf334a Bug 1178850 - Add supporting classes for native JNI calls; r=snorp 2015-07-10 23:41:36 -04:00
Jim Chen
c46e55d3a0 Bug 1178850 - Make mozilla::jni::Param more intuitive to use; r=snorp 2015-07-10 23:41:35 -04:00
Wes Kocher
0f07ce99e1 Backed out 5 changesets (bug 1178850) for android build bustage CLOSED TREE
Backed out changeset 79085d3894e8 (bug 1178850)
Backed out changeset c02b603104ea (bug 1178850)
Backed out changeset d6dab7810669 (bug 1178850)
Backed out changeset 8ee5809f349b (bug 1178850)
Backed out changeset 821b22ce79e1 (bug 1178850)
2015-07-10 14:17:53 -07:00
Jim Chen
1f1f6ebea0 Bug 1178850 - Add supporting classes for native JNI calls; r=snorp 2015-07-10 16:52:52 -04:00
Jim Chen
328f4b5fdc Bug 1178850 - Make mozilla::jni::Param more intuitive to use; r=snorp 2015-07-10 16:52:51 -04:00
Ehsan Akhgari
5cccea6f0f Bug 1145631 - Part 1: Replace MOZ_OVERRIDE and MOZ_FINAL with override and final in the tree; r=froydnj
This patch was automatically generated using the following script:

function convert() {
echo "Converting $1 to $2..."
find . \
       ! -wholename "*/.git*" \
       ! -wholename "obj-ff-dbg*" \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert MOZ_OVERRIDE override
convert MOZ_FINAL final
2015-03-21 12:28:04 -04:00
Jim Chen
eeef0f206c Bug 1116868 - Add templated JNI classes; r=snorp 2015-01-09 19:33:57 -05:00