Fixes #621 and problems with annotations priority.
The new organization of mnit_simple, and its annotations, means that you can compile any of the test_*.nit and it will create a `.apk` with a distinct package. Thus they can be installed side by side, but they all have the same display name :(
Using Java `long` on Android works again, but they are not fully compatible with Nit's `Int`. Java's `long` are on 64 bits, and Nit's `Int` on 32 bit under ARM. There may be data loss.
Pull-Request: #629
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
-#FIXME: Improper way of resolving unjustified metadata conflict
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2014 Frédéric Vachon <fredvac@gmail.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
module complete_simple_android is
- app_name("test all")
java_package("org.nitlanguage.test_all")
- app_version(1, 0)
end
import test_bundle
# Very simple application
module simple is
- app_name("mnit Simple example")
+ app_name("mnit Simple example") # On Android, this name is hidden by the value in `res/values/strings.xml`
app_version(0, 2, git_revision)
end
# limitations under the License.
module simple_android is
- java_package("org.nitlanguage.simple")
android_manifest("""<uses-permission android:name="android.permission.VIBRATE" />""")
end
end
end
- var sources = new Array[MModule]
- var annotations = null
+ var annotations = new HashSet[AAnnotation]
for mmod in mmodule.in_importation.direct_greaters do
var res = priority_annotation_on_modules(name, mmod)
- if res != null then
- sources.add mmod
- annotations = res
- end
+ if res != null then annotations.add res
end
- if sources.length > 1 then
+ if annotations.length > 1 then
+ var locs = new Array[Location]
+ for annot in annotations do locs.add(annot.location)
+
toolcontext.error(mmodule.location,
- "Priority conflict on annotation {name}, it has been defined in: {sources.join(", ")}")
+ "Priority conflict on annotation {name}, it has been defined in: {locs.join(", ")}")
return null
- end
- return annotations
+ else if annotations.length == 1 then
+ return annotations.first
+ else return null
end
end
end
end
- for p in signature.mparameters do params.add(p.name)
+ for p in signature.mparameters do
+ var param_mtype = p.mtype
+ param_mtype = param_mtype.resolve_for(mclass_type, mclass_type, mmodule, true)
+ params.add(to_java_call_context.cast_to(param_mtype, p.name))
+ end
var cname = "(*nit_ffi_jni_env)->CallStatic{jni_signature_alt}Method"
var ccall
fun foo in "Java" `{
System.out.println("Hello world");
`}
+
+ fun bar(i: Int) in "Java" `{
+ System.out.println(i);
+ `}
end
-(new MyClass).foo
+var a = new MyClass
+a.foo
+a.bar(777)