@@ -20,9 +20,11 @@ public class AnnotationProcessor {
2020
2121 public static final String GENERATED_COMMENT =
2222 "// GENERATED CODE\n " +
23- "// Generated by the Java program at /build/annotationProcessors at compile time from\n " +
24- "// annotations on Java methods. To update, change the annotations on the corresponding Java\n " +
25- "// methods and rerun the build. Manually updating this file will cause your build to fail.\n \n " ;
23+ "// Generated by the Java program at /build/annotationProcessors at compile time\n " +
24+ "// from annotations on Java methods. To update, change the annotations on the\n " +
25+ "// corresponding Javamethods and rerun the build. Manually updating this file\n " +
26+ "// will cause your build to fail.\n " +
27+ "\n " ;
2628
2729 public static void main (String [] args ) {
2830 // We expect a list of jars on the commandline. If missing, whinge about it.
@@ -44,29 +46,24 @@ public static void main(String[] args) {
4446 Iterator <ClassWithOptions > jarClassIterator = IterableJarLoadingURLClassLoader .getIteratorOverJars (args );
4547
4648 StringBuilder headerFile = new StringBuilder (GENERATED_COMMENT );
47- headerFile .append ("#ifndef GeneratedJNIWrappers_h__ \n " +
48- "#define GeneratedJNIWrappers_h__\n \n " +
49- "#include \" nsXPCOMStrings.h \" \n " +
50- "#include \" AndroidJavaWrappers.h \ "\n " +
51- "\n " +
52- "namespace mozilla { \n " +
53- "namespace widget {\n " +
54- "namespace android {\n " +
55- "void InitStubs(JNIEnv *env); \n \n " );
49+ headerFile .append (
50+ "#ifndef GeneratedJNIWrappers_h__\n " +
51+ "#define GeneratedJNIWrappers_h__ \n " +
52+ "\n " +
53+ "#include \" mozilla/jni/Refs.h \ "\n " +
54+ " \n " +
55+ "namespace mozilla {\n " +
56+ "namespace widget {\n " +
57+ " \n " );
5658
5759 StringBuilder implementationFile = new StringBuilder (GENERATED_COMMENT );
58- implementationFile .append ("#include \" GeneratedJNIWrappers.h\" \n " +
59- "#include \" AndroidBridgeUtilities.h\" \n " +
60- "#include \" nsXPCOMStrings.h\" \n " +
61- "#include \" AndroidBridge.h\" \n " +
62- "\n " +
63- "namespace mozilla {\n " +
64- "namespace widget {\n " +
65- "namespace android {\n " );
66-
67- // Used to track the calls to the various class-specific initialisation functions.
68- StringBuilder stubInitialiser = new StringBuilder ();
69- stubInitialiser .append ("void InitStubs(JNIEnv *env) {\n " );
60+ implementationFile .append (
61+ "#include \" GeneratedJNIWrappers.h\" \n " +
62+ "#include \" mozilla/jni/Accessors.h\" \n " +
63+ "\n " +
64+ "namespace mozilla {\n " +
65+ "namespace widget {\n " +
66+ "\n " );
7067
7168 while (jarClassIterator .hasNext ()) {
7269 ClassWithOptions aClassTuple = jarClassIterator .next ();
@@ -79,9 +76,7 @@ public static void main(String[] args) {
7976 if (!methodIterator .hasNext ()) {
8077 continue ;
8178 }
82- generatorInstance = new CodeGenerator (aClassTuple .wrappedClass , aClassTuple .generatedName );
83-
84- stubInitialiser .append (" " ).append (aClassTuple .generatedName ).append ("::InitStubs(env);\n " );
79+ generatorInstance = new CodeGenerator (aClassTuple );
8580
8681 // Iterate all annotated members in this class..
8782 while (methodIterator .hasNext ()) {
@@ -103,18 +98,16 @@ public static void main(String[] args) {
10398 implementationFile .append (generatorInstance .getWrapperFileContents ());
10499 }
105100
106- implementationFile .append ('\n' );
107- stubInitialiser .append ("}" );
108- implementationFile .append (stubInitialiser );
109-
110- implementationFile .append ("\n } /* android */\n " +
111- "} /* widget */\n " +
112- "} /* mozilla */\n " );
101+ implementationFile .append (
102+ "\n " +
103+ "} /* widget */\n " +
104+ "} /* mozilla */\n " );
113105
114- headerFile .append ("\n } /* android */\n " +
115- "} /* widget */\n " +
116- "} /* mozilla */\n " +
117- "#endif\n " );
106+ headerFile .append (
107+ "\n " +
108+ "} /* widget */\n " +
109+ "} /* mozilla */\n " +
110+ "#endif // GeneratedJNIWrappers_h__\n " );
118111
119112 writeOutputFiles (headerFile , implementationFile );
120113 long e = System .currentTimeMillis ();
@@ -158,4 +151,4 @@ private static void writeOutputFiles(StringBuilder aHeaderFile, StringBuilder aI
158151 }
159152 }
160153 }
161- }
154+ }
0 commit comments