Commit Graph

72 Commits

Author SHA1 Message Date
Jim Chen
0bd1b97d16 Bug 1292323 - Update annotationProcessor to reflect WrapForJNI changes; r=snorp
Update the code generator and related classes in annotation processor to
use the new WrapForJNI flags. Also add some more sanity checking to make
sure the flags are used correctly.
2016-08-12 23:15:52 -04:00
James Cheng
b85064a2c6 Bug 1291229 - Fix typo for moving Java bindings to mozilla::java namespace. r=jchen
MozReview-Commit-ID: KGAS6EhnwAI
2016-08-05 13:23:44 -04:00
Nathan Froyd
3896afd101 Backout 1fcb956172cd (bug 1291229) for Android build bustage on a CLOSED TREE 2016-08-04 20:42:36 -04:00
James Cheng
139a9bcf21 Bug 1291229 - Fix typo for moving Java bindings to mozilla::java namespace. r=jchen
MozReview-Commit-ID: KGAS6EhnwAI

--HG--
extra : transplant_source : %D5%E1%CE%FB%C9s%BD%97%FD%BF%8C%99%81%94%D1%DB%94%DF%5B%05
2016-08-02 17:50:05 +08:00
Carsten "Tomcat" Book
336105a0de merge mozilla-inbound to mozilla-central a=merge 2016-07-22 11:58:02 +02:00
Jim Chen
6c88865144 Bug 1287946 - Move Java bindings to mozilla::java namespace; r=snorp
Currently, auto-generated Java bindings are in the mozilla::widget
namespace, and that potentially conflicts with code under
widget/android. Moving the bindings to mozilla::java avoids conflicts
and makes it more clear that we're using Java bindings.
2016-07-21 13:49:04 -04:00
Jim Chen
fe52fe774b Bug 1286663 - Add JNI wrapper class for ByteBuffer; r=snorp
Add a wrapper class for ByteBuffer and its associated calls in JNI.
2016-07-21 13:49:04 -04:00
Tom Tromey
5538d692d3 Bug 1286877 - do not set c-basic-offset for python-mode; r=gps
This removes the unnecessary setting of c-basic-offset from all
python-mode files.

This was automatically generated using

    perl -pi -e 's/; *c-basic-offset: *[0-9]+//'

... on the affected files.

The bulk of these files are moz.build files but there a few others as
well.

MozReview-Commit-ID: 2pPf3DEiZqx

--HG--
extra : rebase_source : 0a7dcac80b924174a2c429b093791148ea6ac204
2016-07-14 10:16:42 -06:00
Carsten "Tomcat" Book
eaf9acf7d5 Backed out changeset f623f6ccca25 (Bug 1286663) for another bustage on android on a CLOSED TREE 2016-07-21 08:14:27 +02:00
Carsten "Tomcat" Book
17b47a99fc Backed out changeset 0cf61343793a (bug 1287946) 2016-07-21 08:07:13 +02:00
Jim Chen
3d8eec2482 Bug 1287946 - Move Java bindings to mozilla::java namespace; r=snorp
Currently, auto-generated Java bindings are in the mozilla::widget
namespace, and that potentially conflicts with code under
widget/android. Moving the bindings to mozilla::java avoids conflicts
and makes it more clear that we're using Java bindings.
2016-07-21 00:42:25 -04:00
Jim Chen
bf5b43ab73 Bug 1286663 - Add JNI wrapper class for ByteBuffer; r=snorp
Add a wrapper class for ByteBuffer and its associated calls in JNI.
2016-07-21 00:41:12 -04:00
James Willcox
718f23f9d0 Bug 1280666 - Allow class annotations to set defaults for members when generating Java bindings r=jchen 2016-06-29 17:09:55 -07:00
Jim Chen
9177a4b375 Bug 1277624 - Move JNI class name out of Context; r=snorp
Move the class name strings into ObjectBase, so that the strings can be
overridden by derived classes in other namespaces.
2016-06-27 14:49:55 -04:00
Nathan Froyd
7831fb1c31 Bug 1277650 - part 1 - make generated Natives<>::methods[] const instead of constexpr; r=darchons
clang complains that a constexpr definition of methods[] cannot refer to
members of the incomplete Impl template parameter, and rightly so.
Making these const is sufficient for our purposes, and that enables us
to move the declaration outside of the class, where it will be
instantiated lazily (presumably at the point when |Impl| is a complete
class definition).  We also need to declare the length of methods[], as
other parts of the code require knowing the length of methods[] at
compile time.
2016-06-06 16:58:55 -04:00
Jim Chen
d2bff49120 Bug 1244875 - Update binding generator; r=snorp
Update the automatic binding generator to match the JNI template
changes.
2016-02-09 17:27:28 -05:00
Nick Alexander
7ef65feafd Bug 1228684 - Make annotation processor handle unusual final cases. r=jchen
--HG--
extra : commitid : 3eImvepGLy4
extra : rebase_source : d47cf7ee506e7046b8a11b6a989c78bfa9fabf92
extra : amend_source : 087f3f556123b6f762c99b3ba8c5a9382a13cfc6
2015-11-27 14:21:04 -08:00
Jim Chen
f133e47c1a Bug 1210585 - Use equals to compare Class instances; r=snorp
The code generator uses == and != to compare two instances of Class, but
it really should be using equals because two distinct instances of Class
can refer to the same class type.
2015-10-22 17:45:45 -04:00
Jim Chen
654a730e13 Bug 1210585 - Avoid fields with same name in class and superclass; r=snorp
Java allows a class field to have the same name as a superclass field,
but when we generate bindings for them, they'll end up with the same C++
name and cause an error. This patch makes the SDK processor filter out
any superclass fields that are hidden by a subclass field with the same
name.
2015-10-22 17:45:45 -04:00
Jim Chen
8d2a72b981 Bug 1209574 - Generate constants for non-accessible static final fields; r=snorp
We try to generate a C++ constant for static final fields, but that
was failing for inaccessible fields. Now we set the field to be
accessible so that we do end up generating a C++ constant.
2015-10-08 15:25:49 -04:00
Jim Chen
0b592d615c Bug 1209574 - Generate C++ name for any Java class in chain of declared classes; r=snorp
Right now, when we generate bindings for Java class A, and we encounter
a Java type B, we generate a corresponding C++ name only if A == B,
otherwise we generate a generic "jni::Object" C++ name. For example,

class Foo {
  class Bar {
    Foo getFoo(Bar bar);
  }
}

In C++, Foo.Bar.getFoo would become,

class Foo {
  class Bar {
    jni::Object::LocalRef getFoo(Bar::Param bar);
  };
};

This patch extends the code generator so that any Java class in the
chain of declared classes gets a corresponding C++ name. The above
example now becomes,

class Foo {
  class Bar {
    Foo::LocalRef getFoo(Bar::Param bar);
  };
};
2015-10-08 15:25:49 -04:00
Carsten "Tomcat" Book
37f97c2a3f Backed out changeset 30a7f9d43ffd (bug 1209574) for android perma Failures 2015-10-08 10:06:59 +02:00
Carsten "Tomcat" Book
348a8f0a15 Backed out changeset 9862f86ffe31 (bug 1209574) for Android Perma Failures 2015-10-08 10:06:47 +02:00
Jim Chen
5d16ca8d3b Bug 1209574 - Generate constants for non-accessible static final fields; r=snorp
We try to generate a C++ constant for static final fields, but that
was failing for inaccessible fields. Now we set the field to be
accessible so that we do end up generating a C++ constant.
2015-10-08 01:12:58 -04:00
Jim Chen
8a746d91f9 Bug 1209574 - Generate C++ name for any Java class in chain of declared classes; r=snorp
Right now, when we generate bindings for Java class A, and we encounter
a Java type B, we generate a corresponding C++ name only if A == B,
otherwise we generate a generic "jni::Object" C++ name. For example,

class Foo {
  class Bar {
    Foo getFoo(Bar bar);
  }
}

In C++, Foo.Bar.getFoo would become,

class Foo {
  class Bar {
    jni::Object::LocalRef getFoo(Bar::Param bar);
  };
};

This patch extends the code generator so that any Java class in the
chain of declared classes gets a corresponding C++ name. The above
example now becomes,

class Foo {
  class Bar {
    Foo::LocalRef getFoo(Bar::Param bar);
  };
};
2015-10-08 01:12:57 -04:00
Wes Kocher
f12076ac2e Backed out 5 changesets (bug 1209574) for android tpn bustage
Backed out changeset fb1f06793a67 (bug 1209574)
Backed out changeset 5f0b32b1acc4 (bug 1209574)
Backed out changeset 657332ea4f59 (bug 1209574)
Backed out changeset 9d2c7ed9cd87 (bug 1209574)
Backed out changeset 8376124b6a0c (bug 1209574)
2015-10-07 09:04:39 -07:00
Jim Chen
eb54e04df1 Bug 1209574 - Generate constants for non-accessible static final fields; r=snorp
We try to generate a C++ constant for static final fields, but that
was failing for inaccessible fields. Now we set the field to be
accessible so that we do end up generating a C++ constant.
2015-10-07 08:57:30 -04:00
Jim Chen
4ab3b96976 Bug 1209574 - Generate C++ name for any Java class in chain of declared classes; r=snorp
Right now, when we generate bindings for Java class A, and we encounter
a Java type B, we generate a corresponding C++ name only if A == B,
otherwise we generate a generic "jni::Object" C++ name. For example,

class Foo {
  class Bar {
    Foo getFoo(Bar bar);
  }
}

In C++, Foo.Bar.getFoo would become,

class Foo {
  class Bar {
    jni::Object::LocalRef getFoo(Bar::Param bar);
  };
};

This patch extends the code generator so that any Java class in the
chain of declared classes gets a corresponding C++ name. The above
example now becomes,

class Foo {
  class Bar {
    Foo::LocalRef getFoo(Bar::Param bar);
  };
};
2015-10-07 08:57:30 -04:00
Nick Alexander
c8ee8a09cf Bug 1108782 - Part 1: straighten out Java classpaths. r=glandium
This commit is us getting out of our own way.  We were specifying
-classpath twice, once in $(JAVAC) and once in java-build.mk.  Only
the latter of these is active.  This a problem for ANDROID_EXTRA_JARS
-- those JARs should be on the classpath and input to $(DX) -- and
JARs that should be on the classpath but *not* input to $(DX).  This
commit removes the global flags to $(JAVAC) and adds
JAVA_{BOOT}CLASSPATH_JARS.  This required some hijinkery moving
wildcards to moz.build files, but everything seems to work.

As well as clarifying some parts of the build, part 2 uses this work
to modify the classpath.

--HG--
extra : commitid : 25Ft0BFs88O
extra : rebase_source : 05e3d1da8d42fa89d06ef48baee17bb77df5bd59
extra : histedit_source : 95b82309aca15c5a3c5f5a0eafbdcf75c5e8dfc0
2015-08-31 13:35:05 -07:00
Jim Chen
63dc585f5c Bug 1194360 - Remove use of inherited constructors; r=snorp
GeneratedJNIWrappers.h was updated in bug 1192079 to use inherited
constructors, which is a gcc 4.8 feature. Many people are still using an
older version of NDK which only comes with gcc 4.7.
2015-08-13 16:57:34 -04:00
Jim Chen
2bdb7be558 Bug 1192079 - Use unqualified names when possible; r=snorp
To reduce verbosity of the generated code, this patch makes the code
generator use unqualified names when possible, e.g. use State::Ref
instead of GeckoThread::State::Ref. To accomplish that, function
prototypes now use the C++11 -> syntax for return types.
2015-08-13 00:53:39 -04:00
Jim Chen
7595348845 Bug 1192079 - Support inner classes in generated JNI wrapper; r=snorp
Currently, when we generate JNI wrapper for an inner class, the
resulting C++ class will not actually be a nested class of the enclosing
class. As a result, the class can be confusing to use. For example,
wrapping Java class GeckoThread.State results in two unrelated C++
classes, GeckoThread and State, and it'd be confusing to use State by
itself.

This patch adds support for inner classes. We start by scanning only for
top-level classes, and when processing each top-level class, we
recursively scan for inner classes through
JarClassIterator.getInnerClasses() and CodeGenerator.generateClasses().
For each Java inner classes, the resulting C++ class will be a nested
class. For example, wrapping GeckoThread.State will produce
widget::GeckoThread and widget::GeckoThread::State.
2015-08-13 00:53:39 -04:00
Mark Capella
f3a5fca399 Bug 1191161 - p3 - Rename / Shorten WrapElementForJNI to WrapForJNI, r=jchen
--HG--
rename : mobile/android/base/mozglue/generatorannotations/WrapElementForJNI.java => mobile/android/base/annotation/WrapForJNI.java
2015-08-07 02:09:08 -04:00
Mark Capella
a715087aff Bug 1191161 - p1 - Merge WrapEntireClassForJNI into WrapElementForJNI, r=jchen 2015-08-06 01:55:29 -04:00
Jim Chen
c723648f9d Bug 1186517 - Fix SDKProcessor API version detection; r=snorp
The API version detection functionality was broken in SDKProcessor
because we were passing in "Lpackage/Class;" as the class name rather
than just "package/Class". Also, some classes have a weird situation
where some methods were moved around in later API versions. For example,
some put* and get* methods in Bundle were moved to BaseBundle in API 21.
If we only checked BaseBundle.put*, we would think they are API 21+
only. The workaround is to check both the top-level class and the
declaring class for a member, and choose the lower API level as the
minimal API level for that member.

This patch also fixes bugs in including the right class members.
For SDKProcessor we want to include all public members of a class,
including inherited members, because the private/protected members are
not part of the public API. For AnnotationProcessor, we want to include
all the members declared in that class, including private and
protected members, because we may want to access private/protected
members of our own Java classes from C++.
2015-07-29 15:11:15 -04:00
Jim Chen
64eb7d8aff Bug 1186517 - Adjust white spacing in generated files; r=me 2015-07-29 15:11:15 -04:00
Jim Chen
2a96b6bc16 Bug 1178850 - Generate naive method bindings in annotation processor; r=snorp 2015-07-10 23:41:35 -04:00
Jim Chen
42c05f4a28 Bug 1178850 - Make mozilla::jni::Param more intuitive to use; r=snorp 2015-07-10 23:41:35 -04:00
Wes Kocher
027fd9354a 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
acd92bfffd Bug 1178850 - Generate naive method bindings in annotation processor; r=snorp 2015-07-10 16:52:52 -04:00
Jim Chen
92f97132f9 Bug 1178850 - Make mozilla::jni::Param more intuitive to use; r=snorp 2015-07-10 16:52:51 -04:00
Jim Chen
db34c64f29 Bug 1116589 - Use templated JNI classes in generated bindings; r=snorp 2015-01-09 19:33:57 -05:00
James Willcox
9496c78f68 Bug 1099345 - Add more descriptive debugging output to the Android SDK code generator r=nalexander
--HG--
extra : rebase_source : 47d675ebe19db1a488498a19834674fe2fd8dc4f
2014-11-26 15:16:08 -06:00
Nick Alexander
3cab90a5de Bug 1099501 - Export and use ANDROID_TOOLS where appropriate. r=snorp,bnicholson
In certain configurations, in particular when installing the Android SDK
using HomeBrew, one sees a configuration with symlinks like:

    [brian@brian-macbook git]$ ls -l /usr/local/Cellar/android-sdk/23.0.2/
    total 72
    ...
    lrwxr-xr-x   1 brian  admin    38 Nov 14 16:39 platforms -> ../../../var/lib/android-sdk/platforms
    ...
    drwxr-xr-x  26 brian  admin   884 Nov 14 17:43 tools

In this case, we have
ANDROID_SDK=/usr/local/Cellar/android-sdk/23.0.2/platforms/android-21.

It is an anti-pattern to use ANDORID_SDK/.. to find other paths in the
tree.  This pattern is used in at least two places:

1) When we try to find
/usr/local/Cellar/android-sdk/23.0.2/platforms/android-21/../../tools,
we end up in the /usr/local/var/lib subtree.  This patch works around
that by exporting and using ANDROID_TOOLS; ANDROID_TOOLS itself is
extracted using path matching, rather than following .. through the
filesystem.

2) We also need to use ANDROID_SDK_ROOT rather than
ANDROID_SDK/../.. through-out.

--HG--
extra : rebase_source : 5e0323a94f2b80550f17a624e16f338cdeec406d
2014-11-17 11:12:00 -08:00
James Willcox
4f5b795709 Bug 1086693 - Part 5: Add a 'catchException' mode to JNI generator r=ckitching 2014-11-13 12:47:24 -06:00
James Willcox
f793c98f19 Bug 1086693 - Part 4: Add a lazy initialization mode to CodeGenerator, and use it for SDK bindings r=ckitching 2014-11-13 12:47:24 -06:00
James Willcox
178ca1265d Bug 1086693 - Part 3: Don't generate members that are above a given API version r=ckitching 2014-11-13 12:47:23 -06:00
Nick Alexander
7d9379397e Bug 1086693 - Part 2: Generate and build Android SDK JNI wrappers. r=gps 2014-11-13 12:47:23 -06:00
James Willcox
8d6684fdf9 Bug 1086693 - Part 1: Add SDKProcessor r=ckitching 2014-11-13 12:47:22 -06:00
Chris Kitching
7774990532 Bug 1067056: Remove JavaDomKeyLocation and GeneratorOptions annotation. r=jchen 2014-09-13 17:42:03 -07:00