Merge: Introduce `neo`: a model saver/loader from/to neo4j.
authorJean Privat <jean@pryen.org>
Wed, 23 Jul 2014 18:22:49 +0000 (14:22 -0400)
committerJean Privat <jean@pryen.org>
Wed, 23 Jul 2014 18:22:49 +0000 (14:22 -0400)
The `neo` module can be used to save or load a model from a Neo4j graph database.

Next pull requests will bring tools based on `neo`.

Pull-Request: #606
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

80 files changed:
Makefile
doc/Makefile [deleted file]
doc/git-gen-version.sh [deleted file]
examples/mnit_moles/src/moles.nit
examples/mnit_simple/Makefile
examples/mnit_simple/src/complete_simple_android.nit [new file with mode: 0644]
examples/mnit_simple/src/simple_android.nit
examples/mnit_simple/src/test_assets_and_resources.nit [new file with mode: 0644]
examples/mnit_simple/src/test_audio.nit [new file with mode: 0644]
examples/mnit_simple/src/test_bundle.nit [new file with mode: 0644]
examples/mnit_simple/src/test_shared_preferences.nit [new file with mode: 0644]
examples/mnit_simple/src/test_target_api.nit
lib/android/assets_and_resources.nit
lib/android/audio.nit
lib/android/bundle/bundle.nit
lib/android/java_io.nit
lib/android/shared_preferences/shared_preferences_api10.nit
lib/serialization.nit
lib/standard/string.nit
lib/standard/string_nit.c
lib/standard/string_nit.h
src/abstract_compiler.nit
src/android_platform.nit
src/annotation.nit
src/common_ffi/extern_classes.nit
src/common_ffi/java.nit
src/frontend.nit
src/modelize_class.nit
src/modelize_property.nit
src/naive_interpreter.nit
src/nitmetrics.nit
src/nitni/nitni_base.nit
src/parser_util.nit
src/serialization_phase.nit
tests/base_attr2.nit
tests/base_attr4.nit
tests/base_attr5.nit
tests/base_attr6.nit
tests/base_attr7.nit
tests/base_attr_lazy.nit [new file with mode: 0644]
tests/base_attr_lazy_int.nit [new file with mode: 0644]
tests/base_attr_lazy_nullable.nit [new file with mode: 0644]
tests/base_attr_named_setters.nit [new file with mode: 0644]
tests/base_attr_readonly.nit [new file with mode: 0644]
tests/base_init_noinit.nit [new file with mode: 0644]
tests/base_prot_sig.nit
tests/base_prot_sig2.nit
tests/base_virtual_type.nit
tests/base_virtual_type2.nit
tests/base_virtual_type3.nit
tests/base_virtual_type6.nit
tests/base_virtual_type7.nit
tests/sav/base_attr_lazy.res [new file with mode: 0644]
tests/sav/base_attr_lazy_alt1.res [new file with mode: 0644]
tests/sav/base_attr_lazy_int.res [new file with mode: 0644]
tests/sav/base_attr_lazy_nullable.res [new file with mode: 0644]
tests/sav/base_attr_named_setters.res [new file with mode: 0644]
tests/sav/base_attr_named_setters_alt1.res [new file with mode: 0644]
tests/sav/base_attr_named_setters_alt2.res [new file with mode: 0644]
tests/sav/base_attr_named_setters_alt3.res [new file with mode: 0644]
tests/sav/base_attr_named_setters_alt4.res [new file with mode: 0644]
tests/sav/base_attr_readonly.res [new file with mode: 0644]
tests/sav/base_attr_readonly_alt1.res [new file with mode: 0644]
tests/sav/base_attr_readonly_alt2.res [new file with mode: 0644]
tests/sav/base_attr_readonly_alt3.res [new file with mode: 0644]
tests/sav/base_init_noinit.res [new file with mode: 0644]
tests/sav/base_init_noinit_alt1.res [new file with mode: 0644]
tests/sav/base_init_noinit_alt2.res [new file with mode: 0644]
tests/sav/base_init_noinit_alt3.res [new file with mode: 0644]
tests/sav/base_init_noinit_alt4.res [new file with mode: 0644]
tests/sav/base_init_noinit_alt5.res [new file with mode: 0644]
tests/sav/base_prot_sig_alt7.res
tests/sav/complete_simple_android.res [new file with mode: 0644]
tests/sav/nitg-g/fixme/complete_simple_android.res [moved from tests/sav/nitg-g/fixme/simple_android.res with 100% similarity]
tests/sav/nitg-sg/fixme/complete_simple_android.res [moved from tests/sav/nitg-sg/fixme/simple_android.res with 100% similarity]
tests/sav/nitmetrics.res
tests/test_deserialization.nit
tests/test_ffi_java_types.nit
tests/test_gen_inh.nit
tests/test_serialization.nit

index d51f431..ef24ecb 100644 (file)
--- a/Makefile
+++ b/Makefile
 
 NITCOPT=
 
-all: tools doc/stdlib/index.html
+all: tools
 
 docs: doc/stdlib/index.html doc/nitc/index.html
-       #cd doc; make
 
 tools:
        cd src; make
diff --git a/doc/Makefile b/doc/Makefile
deleted file mode 100644 (file)
index c37eaa8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-all:
-       ./git-gen-version.sh
-       rubber --pdf --inplace nitreference/nitreference.tex
-       rubber --pdf --inplace developpez/nit.tex
-
-clean:
-       rm nit_version.sty 2> /dev/null || true
-       rubber --clean --inplace nitreference/nitreference.tex
-       rubber --clean --inplace developpez/nit.tex
-
-distclean: clean
-       rm nitreference/nitreference.pdf developpez/nit.pdf 2> /dev/null || true
diff --git a/doc/git-gen-version.sh b/doc/git-gen-version.sh
deleted file mode 100755 (executable)
index 145f2f7..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/sh
-
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2008 Jean Privat <jean@pryen.org>
-#
-# 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.
-
-# This program is used to generate version number from git refs.
-# The version number is stored in a dedicated Nit module.
-
-gen_version() {
-       if ! grep "$*" nit_version.sty >/dev/null 2>&1; then
-               cat > nit_version.sty<<END
-% This file was generated by git-gen-version.sh
-\\newcommand\\nitversion{$*}
-END
-               echo "Version $*"
-       fi
-}
-
-VN=$(git describe --always HEAD 2>/dev/null)
-if [ "$?" != "0" ]; then
-       if [ -r ../VERSION ]; then
-               VN="$(cat ../VERSION)"
-       else
-               echo >&2 "Error: no VERSION file and not a .git repository."
-               exit 1
-       fi
-fi
-if [ -z "$VN" ]; then
-       VN="undefined"
-fi
-if [ -n "$1" ]; then
-       VN="${VN}-$1"
-fi
-if [ -n "$(git diff HEAD 2>/dev/null)" ]; then
-       VN="${VN}-dirty"
-fi
-
-gen_version "$VN"
index 08642d1..d61992a 100644 (file)
@@ -17,7 +17,9 @@
 # Classic moles game
 #
 # This is a minimal practical example of the mnit framework.
-module moles
+module moles is
+       app_name("Crazy Groundhogs")
+end
 
 import mnit
 
index efc472f..791adb3 100644 (file)
@@ -6,7 +6,7 @@ linux:
 
 android:
        mkdir -p bin
-       ../../bin/nitg -o bin/simple.apk src/simple_android.nit
+       ../../bin/nitg -o bin/simple.apk src/complete_simple_android.nit
 
 clean:
        rm -rf bin
diff --git a/examples/mnit_simple/src/complete_simple_android.nit b/examples/mnit_simple/src/complete_simple_android.nit
new file mode 100644 (file)
index 0000000..57eead6
--- /dev/null
@@ -0,0 +1,12 @@
+#FIXME: Improper way of resolving unjustified metadata conflict
+module complete_simple_android is
+    app_name("test all")
+       java_package("org.nitlanguage.test_all")
+       app_version(1, 0)
+end
+
+import test_bundle
+import test_audio
+import test_shared_preferences
+import test_assets_and_resources
+import test_target_api
index e36aa83..d92ecc6 100644 (file)
@@ -21,10 +21,7 @@ end
 
 import simple
 import mnit_android
-import android::bundle
-import android::shared_preferences
-import android::assets_and_resources
-import android::audio
+import serialization
 
 in "Java" `{
        import android.content.Context;
@@ -32,169 +29,15 @@ in "Java" `{
 `}
 
 redef class App
-       var soundsp: Sound
-       var soundmp: Sound
-
-       redef fun init_window
-       do
-               super
-               manage_audio_mode
-               # retrieve sound
-               soundsp = load_sound("sound.ogg")
-               soundmp = load_music("xylofon.ogg")
-               default_mediaplayer.looping = true
-               default_mediaplayer.prepare
-               soundmp.play
-       end
-
        redef fun input( ie )
        do
                if ie isa PointerEvent and ie.depressed then 
-                       do_java_stuff
-                       test_bundle
-                       test_shared_preferences
-                       soundsp.play
-                       test_assets
-                       test_resources
+                       test_java_ffi
                end
                return super
        end
 
-       #testing the assets manager
-       fun test_assets
-       do
-               assert asset_manager.bitmap("fighter.png") != null
-       end
-
-       #testing the resources manager
-       fun test_resources do
-               assert resource_manager.string("string_test") == "string test"
-               assert resource_manager.boolean("test_bool") == true
-               assert resource_manager.dimension("test_dimen_1") != null
-               assert resource_manager.dimension("test_dimen_2") != null
-       end
-
-       fun test_bundle
-       do
-               var bundle = new Bundle(self)
-                
-               bundle["anInt"] = 1
-               bundle["aFloat"] = 1.1
-               bundle["aString"] = "A string"
-               bundle["aBool"] = true
-               
-               var int_array = new Array[Int]
-               var bool_array = new Array[Bool]
-
-               var value = true
-
-               for i in [0..5] do
-                       int_array.add(i)
-                       bool_array.add(value)
-                       value = not value
-               end
-
-               bundle["anArrayOfInt"] = int_array
-               bundle["anArrayOfBool"] = bool_array
-
-               assert bundle.int("anInt", 0) == 1
-               assert bundle.int("wrongInt", 0) == 0
-               assert bundle.float("aFloat", 0.0) == 1.1
-               assert bundle.float("wrongFloat", 0.0) == 0.0
-               assert bundle.string("aString") == "A string"
-               assert bundle.string("wrongString") == null
-               assert bundle.bool("aBool", false)
-               assert bundle.bool("wrongBool", false) == false
-               
-               var int_array_test = bundle.array_of_int("anArrayOfInt")
-               var bool_array_test = bundle.array_of_bool("anArrayOfBool")
-
-               value = true
-
-               for i in [0..5] do
-                       assert int_array_test[i] == i
-                       assert bool_array_test[i] == value
-                       value = not value
-               end
-               
-               assert bundle.size == 6
-               assert bundle.has("aBool")
-               assert not bundle.is_empty
-
-               bundle.remove("aString")
-               bundle.remove("anArrayOfBool")
-
-               assert bundle.string("aString") == null
-               assert bundle.array_of_bool("anArrayOfBool") == null
-
-               # Serializable tests
-               var p1 = new Point(10, 10)
-               bundle["aPoint"] = p1
-               var p2 = bundle.deserialize("aPoint")
-
-               assert p1.to_s == p2.to_s
-
-               var point_array = new Array[Point]
-
-               for i in [0..5] do point_array.add(new Point(i, i))
-
-               bundle["anArrayOfPoint"] = point_array
-
-               var deserialized_point_array = bundle.deserialize_array("anArrayOfPoint")
-
-               for i in [0..5] do 
-                       var point = new Point(i, i)
-                       assert deserialized_point_array[i].to_s == point.to_s
-               end
-
-               bundle.clear
-
-               assert bundle.keys.is_empty
-               assert bundle.is_empty
-       end
-
-       fun test_shared_preferences
-       do
-               # Private mode tests
-               var sp = new SharedPreferences.privately(self, "test")
-               sp.add_bool("a_boolean",  true)
-               sp.add_float("a_float", 66.6)
-               sp.add_int("an_int", 666)
-               sp.add_int("a_second_int", 666777)
-               sp.add_long("a_long", 6666666666)
-               sp.add_string("a_string", "A string")
-               sp["another_int"] = 85
-               sp["yet_another_string"] = "Another string"
-               sp.remove("a_second_int")
-
-               # Serialized object test
-               var my_point = new Point(10, 10)
-               sp["a_point"] = my_point
-               var my_deserialized_point = sp["a_point"]
-               assert my_point.to_s == my_deserialized_point.to_s
-
-               assert sp.bool("a_boolean", false) == true
-               assert sp.bool("wrong_boolean", false) == false
-               assert sp.float("a_float", 0.0) != 0.0
-               assert sp.float("wrong_float", 0.0) == 0.0
-               assert sp.int("an_int", 0) == 666
-               assert sp.int("a_second_int", 0) == 0
-               assert sp.long("a_long", 0) == 6666666666
-               assert sp.long("wrong_long", 0) == 0
-               assert sp.string("a_string", "ERROR!") == "A string"
-               assert sp.string("wrong_string", "ERROR!") == "ERROR!"
-               assert sp.long("another_int", 0) == 85
-               assert sp.string("yet_another_string", "ERROR!") == "Another string"
-               assert sp.has("an_int") == true
-               assert sp.has("a_second_int") == false
-
-               sp.clear
-               assert sp.all == null
-
-               sp.destroy
-       end
-
-       fun do_java_stuff import native_activity in "Java" `{
+       fun test_java_ffi import native_activity in "Java" `{
                // + Log (no context needed)
                android.util.Log.d("mnit_simple", "Java within NIT!!!");
 
diff --git a/examples/mnit_simple/src/test_assets_and_resources.nit b/examples/mnit_simple/src/test_assets_and_resources.nit
new file mode 100644 (file)
index 0000000..b2564bf
--- /dev/null
@@ -0,0 +1,46 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2014 Romain Chanoir <romain.chanoir@viacesi.fr>
+#
+# 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.
+
+# Test for the asserts_and_resources module of App.nit framework
+module test_assets_and_resources
+
+import simple_android
+import android::assets_and_resources
+
+redef class App
+       redef fun input( ie )
+       do
+               if ie isa PointerEvent and ie.depressed then 
+                       test_assets
+                       test_resources
+               end
+               return super
+       end
+
+       # Testing the assets manager
+       fun test_assets
+       do
+               assert asset_manager.bitmap("fighter.png") != null
+       end
+
+       # Testing the resources manager
+       fun test_resources do
+               assert resource_manager.string("string_test") == "string test"
+               assert resource_manager.boolean("test_bool") == true
+               assert resource_manager.dimension("test_dimen_1") != null
+               assert resource_manager.dimension("test_dimen_2") != null
+       end
+end
diff --git a/examples/mnit_simple/src/test_audio.nit b/examples/mnit_simple/src/test_audio.nit
new file mode 100644 (file)
index 0000000..5d8981e
--- /dev/null
@@ -0,0 +1,47 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2014 Romain Chanoir <romain.chanoir@viacesi.fr>
+#
+# 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.
+
+# Test for the audio module of App.nit framework
+module test_audio
+
+import simple_android
+import android::audio
+
+redef class App
+       var soundsp: Sound
+       var soundmp: Sound
+
+       redef fun init_window
+       do
+               super
+               manage_audio_mode
+
+               # Retrieve sound
+               soundsp = load_sound("sound.ogg")
+               soundmp = load_music("xylofon.ogg")
+               default_mediaplayer.looping = true
+               default_mediaplayer.prepare
+               soundmp.play
+       end
+
+       redef fun input( ie )
+       do
+               if ie isa PointerEvent and ie.depressed then 
+                       soundsp.play
+               end
+               return super
+       end
+end
diff --git a/examples/mnit_simple/src/test_bundle.nit b/examples/mnit_simple/src/test_bundle.nit
new file mode 100644 (file)
index 0000000..5bfc8d2
--- /dev/null
@@ -0,0 +1,111 @@
+# 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.
+
+# Test for the bundle module of App.nit framework
+module test_bundle
+
+import simple_android
+import android::bundle
+
+redef class App
+       redef fun input ( ie )
+       do
+               if ie isa PointerEvent and ie.depressed then
+                       test_bundle
+               end
+               return super
+       end
+
+       fun test_bundle
+       do
+               var bundle = new Bundle(self)
+                
+               bundle["anInt"] = 1
+               bundle["aFloat"] = 1.1
+               bundle["aString"] = "A string"
+               bundle["aBool"] = true
+               
+               var int_array = new Array[Int]
+               var bool_array = new Array[Bool]
+
+               var value = true
+
+               for i in [0..5] do
+                       int_array.add(i)
+                       bool_array.add(value)
+                       value = not value
+               end
+
+               bundle["anArrayOfInt"] = int_array
+               bundle["anArrayOfBool"] = bool_array
+
+               assert bundle.int("anInt", 0) == 1
+               assert bundle.int("wrongInt", 0) == 0
+               assert bundle.float("aFloat", 0.0) == 1.1
+               assert bundle.float("wrongFloat", 0.0) == 0.0
+               assert bundle.string("aString") == "A string"
+               assert bundle.string("wrongString") == null
+               assert bundle.bool("aBool", false)
+               assert bundle.bool("wrongBool", false) == false
+               
+               var int_array_test = bundle.array_of_int("anArrayOfInt")
+               var bool_array_test = bundle.array_of_bool("anArrayOfBool")
+
+               value = true
+
+               for i in [0..5] do
+                       assert int_array_test[i] == i
+                       assert bool_array_test[i] == value
+                       value = not value
+               end
+               
+               assert bundle.size == 6
+               assert bundle.has("aBool")
+               assert not bundle.is_empty
+
+               bundle.remove("aString")
+               bundle.remove("anArrayOfBool")
+
+               assert bundle.string("aString") == null
+               assert bundle.array_of_bool("anArrayOfBool") == null
+
+               # Serializable tests
+               var p1 = new Point(10, 10)
+               bundle["aPoint"] = p1
+               var p2 = bundle.deserialize("aPoint")
+
+               assert p1.to_s == p2.to_s
+
+               var point_array = new Array[Point]
+
+               for i in [0..5] do point_array.add(new Point(i, i))
+
+               bundle["anArrayOfPoint"] = point_array
+
+               var deserialized_point_array = bundle.deserialize_array("anArrayOfPoint")
+
+               for i in [0..5] do 
+                       var point = new Point(i, i)
+                       assert deserialized_point_array[i].to_s == point.to_s
+               end
+
+               bundle.clear
+
+               assert bundle.keys.is_empty
+               assert bundle.is_empty
+       end
+end
+
diff --git a/examples/mnit_simple/src/test_shared_preferences.nit b/examples/mnit_simple/src/test_shared_preferences.nit
new file mode 100644 (file)
index 0000000..0032f95
--- /dev/null
@@ -0,0 +1,72 @@
+# 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.
+
+# Test for the shared_preferences module of App.nit framework
+module test_shared_preferences
+
+import simple_android
+import android::shared_preferences
+
+redef class App
+       redef fun input ( ie )
+       do
+               if ie isa PointerEvent and ie.depressed then
+                       test_shared_preferences
+               end
+               return super
+       end
+
+       fun test_shared_preferences
+       do
+               # Private mode tests
+               var sp = new SharedPreferences.privately(self, "test")
+               sp.add_bool("a_boolean",  true)
+               sp.add_float("a_float", 66.6)
+               sp.add_int("an_int", 666)
+               sp.add_int("a_second_int", 666777)
+               sp.add_long("a_long", 6666666666)
+               sp.add_string("a_string", "A string")
+               sp["another_int"] = 85
+               sp["yet_another_string"] = "Another string"
+               sp.remove("a_second_int")
+
+               # Serialized object test
+               var my_point = new Point(10, 10)
+               sp["a_point"] = my_point
+               var my_deserialized_point = sp["a_point"]
+               assert my_point.to_s == my_deserialized_point.to_s
+
+               assert sp.bool("a_boolean", false) == true
+               assert sp.bool("wrong_boolean", false) == false
+               assert sp.float("a_float", 0.0) != 0.0
+               assert sp.float("wrong_float", 0.0) == 0.0
+               assert sp.int("an_int", 0) == 666
+               assert sp.int("a_second_int", 0) == 0
+               assert sp.long("a_long", 0) == 6666666666
+               assert sp.long("wrong_long", 0) == 0
+               assert sp.string("a_string", "ERROR!") == "A string"
+               assert sp.string("wrong_string", "ERROR!") == "ERROR!"
+               assert sp["another_int"] == 85
+               assert sp["yet_another_string"] == "Another string"
+               assert sp.has("an_int") == true
+               assert sp.has("a_second_int") == false
+
+               sp.clear
+               assert sp.all == null
+
+               sp.destroy
+       end
+end
index c59b3dc..d5d27ac 100644 (file)
@@ -16,9 +16,9 @@
 
 # Test for the API level related annotations
 module test_target_api is
-       min_sdk_version(10)
-       max_sdk_version(19)
-       target_sdk_version(11)
+       min_api_version(10)
+       max_api_version(19)
+       target_api_version(11)
 end
 
 import simple_android
index ef78d72..d654641 100644 (file)
@@ -175,17 +175,17 @@ extern class NativeResources in "Java" `{ android.content.res.Resources `}
        redef type SELF: NativeResources
 
        fun get_assets:NativeAssetManager in "Java" `{ return recv.getAssets(); `}
-       fun get_color(id: Int): Int in "Java" `{ return recv.getColor(id); `}
-       fun get_boolean(id: Int): Bool in "Java" `{ return recv.getBoolean(id); `}
-       fun get_dimension(id: Int): Int in "Java" `{ return (int)recv.getDimension(id); `}
-       fun get_drawable(id: Int): NativeDrawable in "Java" `{ return recv.getDrawable(id); `}
+       fun get_color(id: Int): Int in "Java" `{ return recv.getColor((int)id); `}
+       fun get_boolean(id: Int): Bool in "Java" `{ return recv.getBoolean((int)id); `}
+       fun get_dimension(id: Int): Int in "Java" `{ return (int)recv.getDimension((int)id); `}
+       fun get_drawable(id: Int): NativeDrawable in "Java" `{ return recv.getDrawable((int)id); `}
        fun get_identifier(name, def_type, def_package: JavaString): Int in "Java" `{ return recv.getIdentifier(name, def_type, def_package); `}
-       fun get_integer(id: Int): Int in "Java" `{ return recv.getInteger(id); `}
-       fun get_string(id: Int): JavaString in "Java" `{ return recv.getString(id); `}
-       fun get_resource_entry_name(resid: Int): JavaString in "Java" `{ return recv.getResourceEntryName(resid); `}
-       fun get_resource_name(resid: Int): JavaString in "Java" `{ return recv.getResourceName(resid); `}
-       fun get_resource_pakage_name(resid: Int): JavaString in "Java" `{ return recv.getResourcePackageName(resid); `}
-       fun get_resource_type_name(resid: Int): JavaString in "Java" `{ return recv.getResourceTypeName(resid); `}
+       fun get_integer(id: Int): Int in "Java" `{ return recv.getInteger((int)id); `}
+       fun get_string(id: Int): JavaString in "Java" `{ return recv.getString((int)id); `}
+       fun get_resource_entry_name(resid: Int): JavaString in "Java" `{ return recv.getResourceEntryName((int)resid); `}
+       fun get_resource_name(resid: Int): JavaString in "Java" `{ return recv.getResourceName((int)resid); `}
+       fun get_resource_pakage_name(resid: Int): JavaString in "Java" `{ return recv.getResourcePackageName((int)resid); `}
+       fun get_resource_type_name(resid: Int): JavaString in "Java" `{ return recv.getResourceTypeName((int)resid); `}
 end
 
 # Resource manager for android resources placed in the `res` folder of your app
@@ -284,7 +284,7 @@ extern class NativeBitmap in "Java" `{ android.graphics.Bitmap `}
 
        # Create a NativeBitmap using a resource ID and the NativeResources
        # Called by the ResourceManager
-       new from_resources(res: NativeResources, id: Int) in "Java" `{ return BitmapFactory.decodeResource(res, id); `}
+       new from_resources(res: NativeResources, id: Int) in "Java" `{ return BitmapFactory.decodeResource(res, (int)id); `}
        fun width: Int in "Java" `{ return recv.getWidth(); `}
        fun height: Int in "Java" `{ return recv.getHeight(); `}
 end
index b46a660..7a19756 100644 (file)
@@ -41,7 +41,7 @@ extern class NativeAudioManager in "Java" `{ android.media.AudioManager `}
        redef type SELF: NativeAudioManager
 
        fun mode: Int in "Java" `{ return recv.getMode(); `}
-       fun mode=(i: Int) in "Java" `{ recv.setMode(i); `}
+       fun mode=(i: Int) in "Java" `{ recv.setMode((int)i); `}
        fun wired_headset_on: Bool in "Java" `{ return recv.isWiredHeadsetOn(); `}
        fun wired_headset_on=(b: Bool) in "Java" `{ recv.setWiredHeadsetOn(b); `}
        fun speakerphone_on: Bool in "Java" `{ return recv.isSpeakerphoneOn(); `}
@@ -74,7 +74,7 @@ extern class NativeMediaPlayer in "Java" `{ android.media.MediaPlayer `}
                }
        `}
 
-       fun create(context: NativeActivity, id: Int): NativeMediaPlayer in "Java" `{ return recv.create(context, id); `}
+       fun create(context: NativeActivity, id: Int): NativeMediaPlayer in "Java" `{ return recv.create(context, (int)id); `}
        fun pause in "Java" `{ recv.pause(); `}
        fun stop in "Java" `{ recv.stop(); `}
        fun playing: Bool in "Java" `{ return recv.isPlaying(); `}
@@ -84,7 +84,7 @@ extern class NativeMediaPlayer in "Java" `{ android.media.MediaPlayer `}
        fun looping=(b: Bool) in "Java" `{ recv.setLooping(b); `}
        fun volume=(vol: Float) in "Java" `{ recv.setVolume((float)vol, (float)vol); `}
        fun both_volume(left_volume, right_volume: Float) in "Java" `{ recv.setVolume((float)left_volume, (float)right_volume); `}
-       fun stream_type=(stream_type: Int) in "Java" `{ recv.setAudioStreamType(stream_type); `}
+       fun stream_type=(stream_type: Int) in "Java" `{ recv.setAudioStreamType((int)stream_type); `}
        fun data_source_fd(fd: NativeFileDescriptor, start_offset, length: Int) in "Java"  `{
                try {
                        recv.setDataSource(fd, start_offset, length);
@@ -110,24 +110,24 @@ extern class NativeSoundPool in "Java" `{ android.media.SoundPool `}
        redef type SELF: NativeSoundPool
 
        new(max_streams, stream_type, src_quality: Int) in "Java" `{
-               return new SoundPool(max_streams, stream_type, src_quality);
+               return new SoundPool((int)max_streams, (int)stream_type, (int)src_quality);
        `}
-       fun load_asset_fd(afd: NativeAssetFileDescriptor, priority: Int): Int in "Java" `{ return recv.load(afd, priority); `}
-       fun load_id(context: NativeActivity, resid, priority: Int): Int in "Java" `{ return recv.load(context, resid, priority); `}
-       fun load_path(path: JavaString, priority: Int): Int in "Java" `{ return recv.load(path, priority); `}
+       fun load_asset_fd(afd: NativeAssetFileDescriptor, priority: Int): Int in "Java" `{ return recv.load(afd, (int)priority); `}
+       fun load_id(context: NativeActivity, resid, priority: Int): Int in "Java" `{ return recv.load(context, (int)resid, (int)priority); `}
+       fun load_path(path: JavaString, priority: Int): Int in "Java" `{ return recv.load(path, (int)priority); `}
        fun play(sound_id: Int, left_volume, right_volume: Float, priority, l: Int, rate: Float): Int in "Java" `{
-               return recv.play(sound_id, (float)left_volume, (float)right_volume, priority, l, (float)rate);
+               return recv.play((int)sound_id, (float)left_volume, (float)right_volume, (int)priority, (int)l, (float)rate);
        `}
-       fun pause(stream_id: Int) in "Java" `{ recv.pause(stream_id); `}
+       fun pause(stream_id: Int) in "Java" `{ recv.pause((int)stream_id); `}
        fun auto_pause in "Java" `{ recv.autoPause(); `}
        fun auto_resume in "Java" `{ recv.autoResume(); `}
-       fun resume(stream_id: Int) in "Java" `{ recv.resume(stream_id); `}
-       fun set_loop(stream_id, l: Int) in "Java" `{ recv.setLoop(stream_id, l); `}
-       fun set_priority(stream_id, priority: Int) in "Java" `{ recv.setPriority(stream_id, priority); `}
-       fun set_rate(stream_id: Int, rate: Float) in "Java" `{ recv.setRate(stream_id, (float)rate); `}
-       fun set_volume(stream_id: Int, left_volume, right_volume: Float) in "Java" `{ recv.setVolume(stream_id, (float)left_volume, (float)right_volume); `}
-       fun stop(stream_id: Int) in "Java" `{ recv.stop(stream_id); `}
-       fun unload(sound_id: Int): Bool in "Java" `{ return recv.unload(sound_id); `}
+       fun resume(stream_id: Int) in "Java" `{ recv.resume((int)stream_id); `}
+       fun set_loop(stream_id, l: Int) in "Java" `{ recv.setLoop((int)stream_id, (int)l); `}
+       fun set_priority(stream_id, priority: Int) in "Java" `{ recv.setPriority((int)stream_id, (int)priority); `}
+       fun set_rate(stream_id: Int, rate: Float) in "Java" `{ recv.setRate((int)stream_id, (float)rate); `}
+       fun set_volume(stream_id: Int, left_volume, right_volume: Float) in "Java" `{ recv.setVolume((int)stream_id, (float)left_volume, (float)right_volume); `}
+       fun stop(stream_id: Int) in "Java" `{ recv.stop((int)stream_id); `}
+       fun unload(sound_id: Int): Bool in "Java" `{ return recv.unload((int)sound_id); `}
 end
 
 
index b8b8390..7a84d4b 100644 (file)
@@ -85,7 +85,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        fun put_integer_array_list(key: JavaString, value: Array[Int]) 
          import Array[Int].length, Array[Int].[] in "Java" `{
                ArrayList<Integer> java_array = 
-                       new ArrayList<Integer>(Array_of_Int_length(value));
+                       new ArrayList<Integer>((int) Array_of_Int_length(value));
                
                for(int i=0; i < java_array.size(); ++i)
                        java_array.add((int) Array_of_Int__index(value, i));
@@ -94,7 +94,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_string_array_list(key: JavaString, value: Array[JavaString])
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
-               ArrayList<String> java_array = new ArrayList<String>(Array_of_JavaString_length(value));
+               ArrayList<String> java_array = new ArrayList<String>((int)Array_of_JavaString_length(value));
                
                for(int i=0; i < java_array.size(); ++i)
                        java_array.add(Array_of_JavaString__index(value, i));
@@ -104,7 +104,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        fun put_char_sequence_array_list(key: JavaString, value: Array[JavaString])
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
                ArrayList<CharSequence> java_array = 
-                 new ArrayList<CharSequence>(Array_of_JavaString_length(value));
+                 new ArrayList<CharSequence>((int)Array_of_JavaString_length(value));
                
                for(int i=0; i < java_array.size(); ++i)
                        java_array.add(Array_of_JavaString__index(value, i));
@@ -113,7 +113,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_boolean_array(key: JavaString, value: Array[Bool])
          import Array[Bool].length, Array[Bool].[] in "Java" `{
-               boolean[] java_array = new boolean[Array_of_Bool_length(value)];
+               boolean[] java_array = new boolean[(int)Array_of_Bool_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Bool__index(value, i);
@@ -122,7 +122,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_byte_array(key: JavaString, value: Array[Int])
          import Array[Int].length, Array[Int].[] in "Java" `{
-               byte[] java_array = new byte[Array_of_Int_length(value)];
+               byte[] java_array = new byte[(int)Array_of_Int_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = (byte) Array_of_Int__index(value, i);
@@ -131,7 +131,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_short_array(key: JavaString, value: Array[Int])
          import Array[Int].length, Array[Int].[] in "Java" `{
-               short[] java_array = new short[Array_of_Int_length(value)];
+               short[] java_array = new short[(int)Array_of_Int_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = (short) Array_of_Int__index(value, i);
@@ -140,7 +140,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_char_array(key: JavaString, value: Array[Char])
          import Array[Char].length, Array[Char].[] in "Java" `{
-               char[] java_array = new char[Array_of_Char_length(value)];
+               char[] java_array = new char[(int)Array_of_Char_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Char__index(value, i);
@@ -149,7 +149,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_int_array(key: JavaString, value: Array[Int])
          import Array[Int].length, Array[Int].[] in "Java" `{
-               int[] java_array = new int[Array_of_Int_length(value)];
+               int[] java_array = new int[(int)Array_of_Int_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = (int) Array_of_Int__index(value, i);
@@ -158,7 +158,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_long_array(key: JavaString, value: Array[Int])
          import Array[Int].length, Array[Int].[] in "Java" `{
-               long[] java_array = new long[Array_of_Int_length(value)];
+               long[] java_array = new long[(int)Array_of_Int_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Int__index(value, i);
@@ -167,7 +167,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_float_array(key: JavaString, value: Array[Float])
          import Array[Float].length, Array[Float].[] in "Java" `{
-               float[] java_array = new float[Array_of_Float_length(value)];
+               float[] java_array = new float[(int)Array_of_Float_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = (float) Array_of_Float__index(value, i);
@@ -176,7 +176,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_double_array(key: JavaString, value: Array[Float])
          import Array[Float].length, Array[Float].[] in "Java" `{
-               double[] java_array = new double[Array_of_Float_length(value)];
+               double[] java_array = new double[(int)Array_of_Float_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Float__index(value, i);
@@ -185,7 +185,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_string_array(key: JavaString, value: Array[JavaString])
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
-               String[] java_array = new String[Array_of_JavaString_length(value)];
+               String[] java_array = new String[(int)Array_of_JavaString_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_JavaString__index(value, i);
@@ -194,7 +194,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun put_char_sequence_array(key: JavaString, value: Array[JavaString])
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
-               CharSequence[] java_array = new CharSequence[Array_of_JavaString_length(value)];
+               CharSequence[] java_array = new CharSequence[(int)Array_of_JavaString_length(value)];
                
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_JavaString__index(value, i);
@@ -222,13 +222,11 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun get_int(key: JavaString): Int in "Java" `{ return recv.getInt(key); `}
        fun get_int_with_def_value(key: JavaString, def_value: Int): Int in "Java" `{
-               return (int) recv.getInt(key, (int) def_value);
+               return recv.getInt(key, (int) def_value);
        `}
-       # FIXME: Get rid of the int cast as soon as the ffi is fixed
-       fun get_long(key: JavaString): Int in "Java" `{ return (int) recv.getLong(key); `}
-       # FIXME: Get rid of the int cast as soon as the ffi is fixed
+       fun get_long(key: JavaString): Int in "Java" `{ return recv.getLong(key); `}
        fun get_long_with_def_value(key: JavaString, def_value: Int): Int in "Java" `{
-               return (int) recv.getLong(key); 
+               return recv.getLong(key); 
        `}
        fun get_float(key: JavaString): Float in "Java" `{
                return (float) recv.getFloat(key); 
@@ -305,7 +303,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
-                       Array_of_Int_add(nit_array, (int) java_array[i]);
+                       Array_of_Int_add(nit_array, java_array[i]);
                        
                return nit_array;
        `}
@@ -317,7 +315,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
-                       Array_of_Int_add(nit_array, (int) java_array[i]);
+                       Array_of_Int_add(nit_array, java_array[i]);
                        
                return nit_array;
        `}
@@ -354,7 +352,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
-                       Array_of_Int_add(nit_array, (int) java_array[i]);
+                       Array_of_Int_add(nit_array, java_array[i]);
                        
                return nit_array;
        `}
index 7b67cb3..bcd70dc 100644 (file)
@@ -128,7 +128,7 @@ extern class NativeFileOutputStream in "Java" `{ java.io.FileOutputStream `}
        `}
        fun write(one_byte: Int) in "Java" `{
                try {
-                       recv.write(one_byte);
+                       recv.write((byte)one_byte);
                }catch(IOException e){
                        e.printStackTrace();
                }
index 577d0d2..81ababc 100644 (file)
@@ -75,14 +75,13 @@ extern class NativeSharedPreferences in "Java" `{ android.content.SharedPreferen
        fun get_int(key: JavaString, def_value: Int): Int in "Java" `{
                int return_value;
                try {
-                       return_value = recv.getInt(key, def_value); 
+                       return_value = recv.getInt(key, (int)def_value); 
                } catch (ClassCastException e) {
                        return def_value;
                }
 
                return return_value;
        `}
-       #FIXME: Get rid of the `int` cast when the ffi is fixed
        fun get_long(key: JavaString, def_value: Int): Int in "Java" `{
                long return_value;
                try {
@@ -118,7 +117,7 @@ extern class NativeSharedPreferencesEditor in "Java" `{ android.content.SharedPr
                return recv.putFloat(key, (float) value); 
        `}
        fun put_int(key: JavaString, value: Int): NativeSharedPreferencesEditor in "Java" `{
-               return recv.putInt(key, value); 
+               return recv.putInt(key, (int)value); 
        `}
        fun put_long(key: JavaString, value: Int): NativeSharedPreferencesEditor in "Java" `{
                return recv.putLong(key, value); 
@@ -169,9 +168,9 @@ class SharedPreferences
 
                // Uses default SharedPreferences if file_name is an empty String
                if (file_name.equals("")) {
-                       sp = context.getPreferences( mode);
+                       sp = context.getPreferences((int)mode);
                } else { 
-                       sp = context.getSharedPreferences(file_name, mode);
+                       sp = context.getSharedPreferences(file_name, (int)mode);
                }
 
                SharedPreferences.Editor editor = sp.edit();
index ae971c9..a87211f 100644 (file)
@@ -65,7 +65,10 @@ interface Deserializer
 
        # Mainly generated method to return the next instance of the givent
        # class by name
-       fun deserialize_class(class_name: String): Object do abort
+       fun deserialize_class(class_name: String): Object do
+               print "Error: doesn't know how to deserialize class \"{class_name}\""
+               abort
+       end
 end
 
 # Instances of this class can be passed to `Serializer::serialize`
index 74ec7a2..9dbb38c 100644 (file)
@@ -1524,15 +1524,14 @@ redef class Int
        end
 
        # C function to convert an nit Int to a NativeString (char*)
-       private fun native_int_to_s(len: Int): NativeString is extern "native_int_to_s"
+       private fun native_int_to_s: NativeString is extern "native_int_to_s"
 
        # return displayable int in base 10 and signed
        #
        #     assert 1.to_s            == "1"
        #     assert (-123).to_s       == "-123"
        redef fun to_s do
-               var len = digit_count(10)
-               return native_int_to_s(len).to_s_with_length(len)
+               return native_int_to_s.to_s
        end
 
        # return displayable int in hexadecimal
index 15979dc..0159249 100644 (file)
@@ -12,8 +12,9 @@
 #include "string_nit.h"
 
 // Integer to NativeString method
-char* native_int_to_s(int recv, int len){
-       char* str = malloc(len + 1);
-       sprintf(str, "%d", recv);
+char* native_int_to_s(long recv){
+       int len = snprintf(NULL, 0, "%ld", recv);
+       char* str = malloc(len);
+       sprintf(str, "%ld", recv);
        return str;
 }
index a6cf69a..311041d 100644 (file)
@@ -13,6 +13,6 @@
  * another product.
  */
 
-char* native_int_to_s(int recv, int len);
+char* native_int_to_s(long recv);
 
 #endif
index a2c08de..fb376ac 100644 (file)
@@ -2121,18 +2121,55 @@ end
 redef class AAttrPropdef
        redef fun compile_to_c(v, mpropdef, arguments)
        do
-               if arguments.length == 1 then
-                       var res = v.read_attribute(self.mpropdef.mproperty, arguments.first)
+               if mpropdef == mreadpropdef then
+                       assert arguments.length == 1
+                       var res
+                       if is_lazy then
+                               var nexpr = n_expr
+                               assert nexpr != null
+                               var set
+                               var ret = self.mpropdef.static_mtype
+                               var useiset = ret.ctype == "val*" and not ret isa MNullableType
+                               var guard = self.mlazypropdef.mproperty
+                               if useiset then
+                                       set = v.isset_attribute(self.mpropdef.mproperty, arguments.first)
+                               else
+                                       set = v.read_attribute(guard, arguments.first)
+                               end
+                               v.add("if(likely({set})) \{")
+                               res = v.read_attribute(self.mpropdef.mproperty, arguments.first)
+                               v.add("\} else \{")
+                               var value = v.expr(nexpr, self.mpropdef.static_mtype)
+                               v.write_attribute(self.mpropdef.mproperty, arguments.first, value)
+                               v.assign(res, value)
+                               if not useiset then
+                                       var true_v = v.new_expr("1", v.bool_type)
+                                       v.write_attribute(guard, arguments.first, true_v)
+                               end
+                               v.add("\}")
+                       else
+                               res = v.read_attribute(self.mpropdef.mproperty, arguments.first)
+                       end
                        v.assign(v.frame.returnvar.as(not null), res)
-               else
+               else if mpropdef == mwritepropdef then
+                       assert arguments.length == 2
                        v.write_attribute(self.mpropdef.mproperty, arguments.first, arguments[1])
+                       if is_lazy then
+                               var ret = self.mpropdef.static_mtype
+                               var useiset = ret.ctype == "val*" and not ret isa MNullableType
+                               if not useiset then
+                                       v.write_attribute(self.mlazypropdef.mproperty, arguments.first, v.new_expr("1", v.bool_type))
+                               end
+                       end
+               else
+                       abort
                end
        end
 
        fun init_expr(v: AbstractCompilerVisitor, recv: RuntimeVariable)
        do
                var nexpr = self.n_expr
-               if nexpr != null then
+               if nexpr != null and not is_lazy then
                        var oldnode = v.current_node
                        v.current_node = self
                        var old_frame = v.frame
@@ -2178,7 +2215,7 @@ redef class AClassdef
                        var i = 1
                        # Collect undefined attributes
                        for npropdef in self.n_propdefs do
-                               if npropdef isa AAttrPropdef and npropdef.n_expr == null then
+                               if npropdef isa AAttrPropdef and npropdef.n_expr == null and not npropdef.noinit then
                                        v.write_attribute(npropdef.mpropdef.mproperty, recv, arguments[i])
                                        i += 1
                                end
index 7de42f4..1bec914 100644 (file)
@@ -218,14 +218,17 @@ $(call import-module,android/native_app_glue)
                        res_dir = "res"
                end
                if res_dir.file_exists then
+                       # copy the res folder to .nit_compile
                        res_dir = res_dir.realpath
                        var target_res_dir = "{android_project_root}"
-                       if target_res_dir.file_exists then
-                               # copy the res folder to .nit_compile
-                               toolcontext.exec_and_check(["cp", "-R", res_dir, target_res_dir], "Android project error")
-                       end
+                       toolcontext.exec_and_check(["cp", "-R", res_dir, target_res_dir], "Android project error")
+               else
+                       # Create our own custom `res/values/string.xml` with the App name
+"""<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="app_name">{{{app_name}}}</string>
+</resources>""".write_to_file "{dir}/res/values/strings.xml"
                end
-
        end
 
        redef fun write_makefile(compiler, compile_dir, cfiles)
index 4daafef..a0d397e 100644 (file)
@@ -19,6 +19,37 @@ import parser
 import modelbuilder
 import literal
 
+redef class Prod
+       super ANode
+
+       # Try to get its single annotation with a given name
+       # If there is no such an annotation, null is returned.
+       # If there is more than one annotation, a error message is printed and the first annotation is returned
+       fun get_single_annotation(name: String, modelbuilder: ModelBuilder): nullable AAnnotation
+       do
+               var res = get_annotations(name)
+               if res.is_empty then return null
+               if res.length > 1 then
+                       modelbuilder.error(res[1], "Error: multiple annotation `{name}`. A previous one is defined line {res[0].location.line_start}")
+               end
+               return res.first
+       end
+
+       # Return all its annotations of a given name in the order of their declaration
+       # Retun an empty array if no such an annotation.
+       fun get_annotations(name: String): Array[AAnnotation]
+       do
+               var res = new Array[AAnnotation]
+               var nas = n_annotations
+               if nas == null then return res
+               for na in nas.n_items do
+                       if na.name != name then continue
+                       res.add(na)
+               end
+               return res
+       end
+end
+
 redef class AAnnotation
        # The name of the annotation
        fun name: String
@@ -53,6 +84,20 @@ redef class AAnnotation
                modelbuilder.error(self, "Annotation error: \"{name}\" expects a single Int as argument.")
                return null
        end
+
+       # Get the single argument of `self` as an identifier.
+       # Raise error and return null on any inconsistency.
+       fun arg_as_id(modelbuilder: ModelBuilder): nullable String
+       do
+               var args = n_args
+               if args.length == 1 then
+                       var arg = args.first.as_id
+                       if arg != null then return arg
+               end
+
+               modelbuilder.error(self, "Annotation error: \"{name}\" expects a single identifier as argument.")
+               return null
+       end
 end
 
 redef class AAtArg
index 0ab7b96..e1b8463 100644 (file)
@@ -22,7 +22,8 @@ import ffi_base
 redef class ToolContext
        var extern_classes_typing_phase_ast: Phase = new ExternClassesTypingPhaseAst(self, [ffi_language_assignation_phase])
 
-       var extern_classes_typing_phase_model: Phase = new ExternClassesTypingPhaseModel(self, [extern_classes_typing_phase_ast, modelize_class_phase])
+       var extern_classes_typing_phase_model: Phase = new ExternClassesTypingPhaseModel(self,
+               [extern_classes_typing_phase_ast, modelize_class_phase, modelize_property_phase])
 end
 
 # Assigns the `ftype` to class definitions, work on the AST only
index 2e499d3..eefb5c6 100644 (file)
@@ -468,7 +468,7 @@ redef class MClassType
                        replace('/', ".").replace('$', ".").replace(' ', "").replace('\n',"")
                if mclass.name == "Bool" then return "boolean"
                if mclass.name == "Char" then return "char"
-               if mclass.name == "Int" then return "int"
+               if mclass.name == "Int" then return "long"
                if mclass.name == "Float" then return "double"
                return super
        end
@@ -479,7 +479,7 @@ redef class MClassType
                if ftype isa ForeignJavaType then return "jobject"
                if mclass.name == "Bool" then return "jboolean"
                if mclass.name == "Char" then return "jchar"
-               if mclass.name == "Int" then return "jint"
+               if mclass.name == "Int" then return "jlong"
                if mclass.name == "Float" then return "jdouble"
                return super
        end
@@ -510,7 +510,7 @@ redef class MClassType
                end
                if mclass.name == "Bool" then return "Z"
                if mclass.name == "Char" then return "C"
-               if mclass.name == "Int" then return "I"
+               if mclass.name == "Int" then return "J"
                if mclass.name == "Float" then return "D"
                return super
        end
@@ -521,7 +521,7 @@ redef class MClassType
                if ftype isa ForeignJavaType then return "Object"
                if mclass.name == "Bool" then return "Boolean"
                if mclass.name == "Char" then return "Char"
-               if mclass.name == "Int" then return "Int"
+               if mclass.name == "Int" then return "Long"
                if mclass.name == "Float" then return "Double"
                return super
        end
index 62c1d4a..3d635a3 100644 (file)
@@ -37,7 +37,8 @@ redef class ToolContext
                # Force easy warnings before intraproc-errors
                phases.add_edge(scope_phase, simple_misc_analysis_phase)
                # Code genrated by the serialization phase must be analyzed for literals
-               phases.add_edge(literal_phase, serialization_phase)
+               phases.add_edge(literal_phase, serialization_phase_pre_model)
+               phases.add_edge(modelize_class_phase, serialization_phase_pre_model)
                return true
        end
 end
index 09b7081..5f99e51 100644 (file)
@@ -380,7 +380,10 @@ redef class ModelBuilder
                                assert mtype isa MClassType
                                var sc = mtype.mclass
                                if not parents.has(sc) or sc == objectclass then
-                                       warning(ntype, "Warning: superfluous super-class {mtype} in class {mclassdef.mclass}.")
+                                       # Skip the warning on generated code
+                                       if ntype.location.file != null and not ntype.location.file.filename.is_empty then
+                                               warning(ntype, "Warning: superfluous super-class {mtype} in class {mclassdef.mclass}.")
+                                       end
                                else if not seen_parents.has_key(sc) then
                                        seen_parents[sc] = ntype
                                else
index 938a3a0..fb21a65 100644 (file)
@@ -18,6 +18,7 @@
 module modelize_property
 
 import modelize_class
+import annotation
 
 redef class ToolContext
        var modelize_property_phase: Phase = new ModelizePropertyPhase(self, [modelize_class_phase])
@@ -118,8 +119,17 @@ redef class ModelBuilder
                var mparameters = new Array[MParameter]
                var anode: nullable ANode = null
                for npropdef in nclassdef.n_propdefs do
-                       if npropdef isa AAttrPropdef and npropdef.n_expr == null then
+                       if npropdef isa AAttrPropdef then
                                if npropdef.mpropdef == null then return # Skip broken attribute
+                               var at = npropdef.get_single_annotation("noinit", self)
+                               if at != null then
+                                       npropdef.noinit = true
+                                       if npropdef.n_expr != null then
+                                               self.error(at, "Error: `noinit` attributes cannot have an initial value")
+                                       end
+                                       continue # Skip noinit attributes
+                               end
+                               if npropdef.n_expr != null then continue
                                var paramname = npropdef.mpropdef.mproperty.name.substring_from(1)
                                var ret_type = npropdef.mpropdef.static_mtype
                                if ret_type == null then return
@@ -632,10 +642,23 @@ end
 redef class AAttrPropdef
        redef type MPROPDEF: MAttributeDef
 
+       # Is the node tagged `noinit`?
+       var noinit = false
+
+       # Is the node taggeg lazy?
+       var is_lazy = false
+
+       # The guard associated to a lasy attribute.
+       # Because some engines does not have a working `isset`,
+       # this additionnal attribute is used to guard the lazy initialization.
+       # TODO: to remove once isset is correctly implemented
+       var mlazypropdef: nullable MAttributeDef
+
        # The associated getter (read accessor) if any
        var mreadpropdef: nullable MMethodDef writable
        # The associated setter (write accessor) if any
        var mwritepropdef: nullable MMethodDef writable
+
        redef fun build_property(modelbuilder, mclassdef)
        do
                var mclass = mclassdef.mclass
@@ -705,15 +728,44 @@ redef class AAttrPropdef
                        modelbuilder.mpropdef2npropdef[mreadpropdef] = self
                        mreadpropdef.mdoc = mpropdef.mdoc
 
+                       var atlazy = self.get_single_annotation("lazy", modelbuilder)
+                       if atlazy != null then
+                               if n_expr == null then
+                                       modelbuilder.error(atlazy, "Error: a lazy attribute needs a value")
+                               end
+                               is_lazy = true
+                               var mlazyprop = new MAttribute(mclassdef, "lazy _" + name, none_visibility)
+                               var mlazypropdef = new MAttributeDef(mclassdef, mlazyprop, self.location)
+                               self.mlazypropdef = mlazypropdef
+                       end
+
+                       var atreadonly = self.get_single_annotation("readonly", modelbuilder)
+                       if atreadonly != null then
+                               if n_expr == null then
+                                       modelbuilder.error(atreadonly, "Error: a readonly attribute needs a value")
+                               end
+                               # No setter, so just leave
+                               return
+                       end
+
                        var writename = name + "="
                        var nwritable = self.n_writable
+                       var atwritable = self.get_single_annotation("writable", modelbuilder)
+                       if atwritable != null then
+                               if not atwritable.n_args.is_empty then
+                                       writename = atwritable.arg_as_id(modelbuilder) or else writename
+                               end
+                       end
                        var mwriteprop = modelbuilder.try_get_mproperty_by_name(nid2, mclassdef, writename).as(nullable MMethod)
                        var nwkwredef: nullable Token = null
                        if nwritable != null then nwkwredef = nwritable.n_kwredef
+                       if atwritable != null then nwkwredef = atwritable.n_kwredef
                        if mwriteprop == null then
                                var mvisibility
                                if nwritable != null then
                                        mvisibility = new_property_visibility(modelbuilder, mclassdef, nwritable.n_visibility)
+                               else if atwritable != null then
+                                       mvisibility = new_property_visibility(modelbuilder, mclassdef, atwritable.n_visibility)
                                else
                                        mvisibility = private_visibility
                                end
@@ -723,6 +775,8 @@ redef class AAttrPropdef
                                if not self.check_redef_keyword(modelbuilder, mclassdef, nwkwredef or else n_kwredef, true, mwriteprop) then return
                                if nwritable != null then
                                        check_redef_property_visibility(modelbuilder, nwritable.n_visibility, mwriteprop)
+                               else if atwritable != null then
+                                       check_redef_property_visibility(modelbuilder, atwritable.n_visibility, mwriteprop)
                                end
                        end
                        mclassdef.mprop2npropdef[mwriteprop] = self
@@ -807,7 +861,7 @@ redef class AAttrPropdef
                        mreadpropdef.msignature = msignature
                end
 
-               var msritepropdef = self.mwritepropdef
+               var mwritepropdef = self.mwritepropdef
                if mwritepropdef != null then
                        var name: String
                        if n_id != null then
@@ -819,6 +873,11 @@ redef class AAttrPropdef
                        var msignature = new MSignature([mparameter], null)
                        mwritepropdef.msignature = msignature
                end
+
+               var mlazypropdef = self.mlazypropdef
+               if mlazypropdef != null then
+                       mlazypropdef.static_mtype = modelbuilder.model.get_mclasses_by_name("Bool").first.mclass_type
+               end
        end
 
        redef fun check_signature(modelbuilder)
index fc6cbfc..138c7e2 100644 (file)
@@ -441,6 +441,13 @@ private class NaiveInterpreter
                recv.attributes[mproperty] = value
        end
 
+       # Is the attribute `mproperty` initialized the instance `recv`?
+       fun isset_attribute(mproperty: MAttribute, recv: Instance): Bool
+       do
+               assert recv isa MutableInstance
+               return recv.attributes.has_key(mproperty)
+       end
+
        # Collect attributes of a type in the order of their init
        fun collect_attr_propdef(mtype: MType): Array[AAttrPropdef]
        do
@@ -982,28 +989,26 @@ redef class AAttrPropdef
                var recv = args.first
                assert recv isa MutableInstance
                var attr = self.mpropdef.mproperty
-               if args.length == 1 then
-                       return v.read_attribute(attr, recv)
-               else
+               if mpropdef == mreadpropdef then
+                       assert args.length == 1
+                       if not is_lazy or v.isset_attribute(attr, recv) then return v.read_attribute(attr, recv)
+                       return evaluate_expr(v, recv)
+               else if mpropdef == mwritepropdef then
                        assert args.length == 2
                        v.write_attribute(attr, recv, args[1])
                        return null
+               else
+                       abort
                end
        end
 
        # Evaluate and set the default value of the attribute in `recv`
        private fun init_expr(v: NaiveInterpreter, recv: Instance)
        do
-               assert recv isa MutableInstance
+               if is_lazy then return
                var nexpr = self.n_expr
                if nexpr != null then
-                       var f = new Frame(self, self.mpropdef.as(not null), [recv])
-                       v.frames.unshift(f)
-                       var val = v.expr(nexpr)
-                       assert val != null
-                       v.frames.shift
-                       assert not v.is_escaping
-                       v.write_attribute(self.mpropdef.mproperty, recv, val)
+                       evaluate_expr(v, recv)
                        return
                end
                var mtype = self.mpropdef.static_mtype.as(not null)
@@ -1012,6 +1017,21 @@ redef class AAttrPropdef
                        v.write_attribute(self.mpropdef.mproperty, recv, v.null_instance)
                end
        end
+
+       private fun evaluate_expr(v: NaiveInterpreter, recv: Instance): Instance
+       do
+               assert recv isa MutableInstance
+               var nexpr = self.n_expr
+               assert nexpr != null
+               var f = new Frame(self, self.mpropdef.as(not null), [recv])
+               v.frames.unshift(f)
+               var val = v.expr(nexpr)
+               assert val != null
+               v.frames.shift
+               assert not v.is_escaping
+               v.write_attribute(self.mpropdef.mproperty, recv, val)
+               return val
+       end
 end
 
 redef class AClassdef
@@ -1031,7 +1051,7 @@ redef class AClassdef
                var i = 1
                # Collect undefined attributes
                for npropdef in self.n_propdefs do
-                       if npropdef isa AAttrPropdef and npropdef.n_expr == null then
+                       if npropdef isa AAttrPropdef and not npropdef.noinit and npropdef.n_expr == null then
                                v.write_attribute(npropdef.mpropdef.mproperty, recv, args[i])
                                i += 1
                        end
@@ -1669,8 +1689,7 @@ redef class AIssetAttrExpr
                if recv == null then return null
                if recv.mtype isa MNullType then fatal(v, "Receiver is null")
                var mproperty = self.mproperty.as(not null)
-               assert recv isa MutableInstance
-               return v.bool_instance(recv.attributes.has_key(mproperty))
+               return v.bool_instance(v.isset_attribute(mproperty, recv))
        end
 end
 
index ab95c3d..ee8b827 100644 (file)
@@ -22,7 +22,7 @@ import metrics
 
 # Create a tool context to handle options and paths
 var toolcontext = new ToolContext
-toolcontext.tooldescription = "Usage: nitmetrics [OPTION]... <file.nit>...\mComputes various metrics on Nit programs."
+toolcontext.tooldescription = "Usage: nitmetrics [OPTION]... <file.nit>...\nComputes various metrics on Nit programs."
 
 # We do not add other options, so process them now!
 toolcontext.process_options(args)
index dd2fe10..cc0ffa2 100644 (file)
@@ -90,7 +90,7 @@ redef class MClassType
                if name == "Bool" then return "int"
                if name == "Char" then return "char"
                if name == "Float" then return "double"
-               if name == "Int" then return "int"
+               if name == "Int" then return "long"
                if name == "NativeString" then return "char*"
                if mclass.kind == extern_kind then
                        var ctype = mclass.ctype
@@ -105,7 +105,7 @@ redef class MClassType
                if name == "Bool" then return "int"
                if name == "Char" then return "char"
                if name == "Float" then return "double"
-               if name == "Int" then return "int"
+               if name == "Int" then return "long"
                if name == "NativeString" then return "char*"
                if mclass.kind == extern_kind then return "void*"
                return "struct nitni_instance *"
index f23ccda..54ccab2 100644 (file)
@@ -83,6 +83,20 @@ redef class ToolContext
                return nexpr
        end
 
+       # Parse a super class declaration
+       # Fatal error if the `string` is not a syntactically correct super class declaration
+       fun parse_superclass(string: String): ASuperclass
+       do
+               var mod_string = "class Dummy\nsuper {string}\nend"
+               var nclassdef = parse_classdef(mod_string).as(AStdClassdef)
+               var nsuperclasses = nclassdef.n_superclasses
+               if nsuperclasses.length != 1 then
+                       self.fatal_error(null, "Fatal Error: not a super class declaration")
+                       abort
+               end
+               return nsuperclasses.first
+       end
+
        # Try to parse the `string` as something
        #
        # Returns the first possible syntacticaly correct type among:
index f565f56..c3b0dc0 100644 (file)
@@ -21,15 +21,19 @@ module serialization_phase
 
 import phase
 import parser_util
+import modelize_property
+intrude import modelize_class
 
 redef class ToolContext
-       var serialization_phase: Phase = new SerializationPhase(self, null)
+       var serialization_phase_pre_model: Phase = new SerializationPhasePreModel(self, null)
+       var serialization_phase_post_model: Phase = new SerializationPhasePostModel(self,
+               [modelize_class_phase, serialization_phase_pre_model])
+
+       private fun place_holder_type_name: String do return "PlaceHolderTypeWhichShouldNotExist"
 end
 
-# TODO automaticaly add Serializable as a super class
-# TODO Sequences
 # TODO add annotations on attributes (volatile, sensitive or do_not_serialize?)
-private class SerializationPhase
+private class SerializationPhasePreModel
        super Phase
 
        redef fun process_annotated_node(nclassdef, nat)
@@ -41,6 +45,11 @@ private class SerializationPhase
                        return
                end
 
+               # Add `super Serializable`
+               var sc = toolcontext.parse_superclass("Serializable")
+               sc.location = nat.location
+               nclassdef.n_superclasses.add sc
+
                generate_serialization_method(nclassdef)
 
                generate_deserialization_init(nclassdef)
@@ -48,6 +57,9 @@ private class SerializationPhase
 
        redef fun process_nmodule(nmodule)
        do
+               # Clear the cache of constructors to review before adding to it
+               nmodule.inits_to_retype.clear
+
                # collect all classes
                var auto_serializable_nclassdefs = new Array[AStdClassdef]
                for nclassdef in nmodule.n_classdefs do
@@ -93,20 +105,27 @@ private class SerializationPhase
                code.add "      v.notify_of_creation self"
 
                for attribute in npropdefs do if attribute isa AAttrPropdef then
-                       if attribute.n_type == null then
-                               toolcontext.error(attribute.location, "NOT YET IMPLEMENTED: all attributes of an auto_serialized class definition must define a type.")
-                               continue
+                       var n_type = attribute.n_type
+                       var type_name
+                       if n_type == null then
+                               # Use a place holder, we will replace it with the infered type after the model phases
+                               type_name = toolcontext.place_holder_type_name
+                       else
+                               type_name = n_type.type_name
                        end
                        var name = attribute.name
-                       var type_name = attribute.type_name
+
                        code.add ""
                        code.add "\tvar {name} = v.deserialize_attribute(\"{name}\")"
-                       code.add "\tassert {name} isa {type_name} else print \"Expected attribute '{name}' to be of type '{type_name}'\""
+                       code.add "\tassert {name} isa {type_name} else print \"Unsupported type for attribute '{name}', got '\{{name}.class_name\}' (ex {type_name})\""
                        code.add "\tself.{name} = {name}"
                end
 
                code.add "end"
-               npropdefs.add(toolcontext.parse_propdef(code.join("\n")))
+
+               var npropdef = toolcontext.parse_propdef(code.join("\n")).as(AConcreteInitPropdef)
+               npropdefs.add npropdef
+               nclassdef.parent.as(AModule).inits_to_retype.add npropdef
        end
 
        # Added to the abstract serialization service
@@ -129,13 +148,13 @@ private class SerializationPhase
                        code.add "      redef fun deserialize_class(name)"
                        code.add "      do"
                else
-                       toolcontext.error(deserializer_npropdef.location, "Annotation error: you cannont define Deserializer::deserialize_class in a module where you use \"auto_serializable\".")
+                       toolcontext.error(deserializer_npropdef.location, "Annotation error: you cannot define Deserializer::deserialize_class in a module where you use \"auto_serializable\".")
                        return
                end
 
                for nclassdef in nclassdefs do
                        var name = nclassdef.n_id.text
-                       if not name.chars.has('[') then # FIXME this is a temporary hack
+                       if nclassdef.n_formaldefs.is_empty then
                                code.add "              if name == \"{name}\" then return new {name}.from_deserializer(self)"
                        end
                end
@@ -152,23 +171,75 @@ private class SerializationPhase
        end
 end
 
+private class SerializationPhasePostModel
+       super Phase
+
+       redef fun process_nmodule(nmodule)
+       do
+               for npropdef in nmodule.inits_to_retype do
+                       var v = new PreciseTypeVisitor(npropdef, npropdef.mpropdef.mclassdef, toolcontext)
+                       npropdef.accept_precise_type_visitor v
+               end
+       end
+end
+
+# Visitor on generated constructors to replace the expected type of deserialized attributes
+private class PreciseTypeVisitor
+       super Visitor
+
+       var npropdef: AConcreteInitPropdef
+       var mclassdef: MClassDef
+       var toolcontext: ToolContext
+
+       init(npropdef: AConcreteInitPropdef, mclassdef: MClassDef, toolcontext: ToolContext)
+       do
+               self.npropdef = npropdef
+               self.mclassdef = mclassdef
+               self.toolcontext = toolcontext
+       end
+
+       redef fun visit(n) do n.accept_precise_type_visitor(self)
+end
+
+redef class ANode
+       private fun accept_precise_type_visitor(v: PreciseTypeVisitor) do visit_all(v)
+end
+
+redef class AIsaExpr
+       redef fun accept_precise_type_visitor(v)
+       do
+               if n_type.collect_text != v.toolcontext.place_holder_type_name then return
+
+               var attr_name = "_" + n_expr.collect_text
+               for mattrdef in v.mclassdef.mpropdefs do
+                       if mattrdef isa MAttributeDef and mattrdef.name == attr_name then
+                               var new_ntype = v.toolcontext.parse_something(mattrdef.static_mtype.to_s)
+                               n_type.replace_with new_ntype
+                               break
+                       end
+               end
+       end
+end
+
 redef class AAttrPropdef
        private fun name: String
        do
                if n_id == null then return n_id2.text
                return n_id.text
        end
+end
 
+redef class AType
        private fun type_name: String
        do
-               var name = n_type.n_id.text
+               var name = n_id.text
 
-               if n_type.n_kwnullable != null then name = "nullable {name}"
+               if n_kwnullable != null then name = "nullable {name}"
 
-               var types = n_type.n_types
+               var types = n_types
                if not types.is_empty then
                        var params = new Array[String]
-                       for t in types do params.add(t.n_id.text)
+                       for t in types do params.add(t.type_name)
                        return "{name}[{params.join(", ")}]"
                else return name
        end
@@ -185,6 +256,8 @@ redef class AModule
 
                return null
        end
+
+       private var inits_to_retype = new Array[AConcreteInitPropdef]
 end
 
 redef class AStdClassdef
index 204b0c9..03c8413 100644 (file)
@@ -19,17 +19,17 @@ class A
        protected var a2: Object = self
        private var a3: Object = self
 
-       var a4: Object writable = self
-       protected var a5: Object writable = self
-       private var a6: Object writable = self
+       var a4: Object = self is writable
+       protected var a5: Object = self is writable
+       private var a6: Object = self is writable
 
-       var a7: Object protected writable = self
-       protected var a8: Object protected writable = self
-       private var a9: Object protected writable = self
+       var a7: Object = self is protected writable
+       protected var a8: Object = self is protected writable
+       private var a9: Object = self is protected writable
 
-       var a10: Object private writable = self
-       protected var a11: Object private writable = self
-       private var a12: Object private writable = self
+       var a10: Object = self is private writable
+       protected var a11: Object = self is private writable
+       private var a12: Object = self is private writable
 
        var cpt: Int = 0
 
index f7bf6a7..b8f02dc 100644 (file)
@@ -24,8 +24,8 @@ end
 class B
        super A
        redef var foo: Int = 20
-       var bar: Int redef writable = 30
-       redef var baz: Int redef writable = 40
+       var bar: Int = 30 is redef writable
+       redef var baz: Int = 40 is redef writable
 end
 
 class C
index 56c88da..8bb4171 100644 (file)
@@ -33,24 +33,24 @@ class B
        super A
        #alt1#var foo: Int = 10
        #alt2#redef var foo: Int = 10
-       #alt3#var foo: Int writable = 10
-       #alt4#redef var foo: Int writable = 10
-       #alt5#var foo: Int redef writable = 10
-       #alt6#redef var foo: Int redef writable = 10
+       #alt3#var foo: Int = 10 is writable
+       #alt4#redef var foo: Int = 10 is writable
+       #alt5#var foo: Int = 10 is redef writable
+       #alt6#redef var foo: Int = 10 is redef writable
        #alt7#redef var foo
        #alt11#var bar: Int = 20
        #alt12#redef var bar: Int = 20
-       #alt13#var bar: Int writable = 20
-       #alt14#redef var bar: Int writable = 20
-       #alt15#var bar: Int redef writable = 20
-       #alt16#redef var bar: Int redef writable = 20
+       #alt13#var bar: Int = 20 is writable
+       #alt14#redef var bar: Int = 20 is writable
+       #alt15#var bar: Int = 20 is redef writable
+       #alt16#redef var bar: Int = 20 is redef writable
        #alt17#redef var bar
        #alt21#var baz: Int = 30
        #alt22#redef var baz: Int = 30
-       #alt23#var baz: Int writable = 30
-       #alt24#redef var baz: Int writable = 30
-       #alt25#var baz: Int redef writable = 30
-       #alt26#redef var baz: Int redef writable = 30
+       #alt23#var baz: Int = 30 is writable
+       #alt24#redef var baz: Int = 30 is writable
+       #alt25#var baz: Int = 30 is redef writable
+       #alt26#redef var baz: Int = 30 is redef writable
        #alt27#redef var baz
 end
 
index a83f792..03fe206 100644 (file)
@@ -37,7 +37,7 @@ class B
                i.output
                super(i+30)
        end
-       redef var vaz: Int redef writable = 40
+       redef var vaz: Int = 40 is redef writable
 end
 
 var b = new B
index c3605cc..2aec253 100644 (file)
@@ -32,8 +32,8 @@ end
 class B
        super A
        #alt1#redef var foo: Bool = true
-       #alt2#var bar: Bool redef writable = true
-       #alt3#redef var baz: Bool redef writable = true
+       #alt2#var bar: Bool = true is redef writable
+       #alt3#redef var baz: Bool = true is redef writable
 end
 
 var b = new B
diff --git a/tests/base_attr_lazy.nit b/tests/base_attr_lazy.nit
new file mode 100644 (file)
index 0000000..d271411
--- /dev/null
@@ -0,0 +1,48 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# 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.
+
+import kernel
+
+class Foo
+       var a1: Object = fa1 is lazy
+       var a2: Object = fa2 is lazy
+       fun fa1: Object do
+               1.output
+               return 10
+       end
+       fun fa2: Object do
+               2.output
+               return 20
+       end
+       #alt1#var a3: Object is lazy
+end
+
+var f = new Foo
+f.a1.output
+f.a1.output
+f.a2.output
+f.a2.output
+'\n'.output
+
+var g = new Foo
+g.a2.output
+g.a1.output
+g.a2.output
+g.a1.output
+'\n'.output
+
+var h = new Foo
+h.a1 = 100
+h.a1.output
+h.a1.output
diff --git a/tests/base_attr_lazy_int.nit b/tests/base_attr_lazy_int.nit
new file mode 100644 (file)
index 0000000..5197740
--- /dev/null
@@ -0,0 +1,47 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# 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.
+
+import kernel
+
+class Foo
+       var a1: Int = fa1 is lazy
+       var a2: Int = fa2 is lazy
+       fun fa1: Int do
+               1.output
+               return 10
+       end
+       fun fa2: Int do
+               2.output
+               return 20
+       end
+end
+
+var f = new Foo
+f.a1.output
+f.a1.output
+f.a2.output
+f.a2.output
+'\n'.output
+
+var g = new Foo
+g.a2.output
+g.a1.output
+g.a2.output
+g.a1.output
+'\n'.output
+
+var h = new Foo
+h.a1 = 100
+h.a1.output
+h.a1.output
diff --git a/tests/base_attr_lazy_nullable.nit b/tests/base_attr_lazy_nullable.nit
new file mode 100644 (file)
index 0000000..ba3b404
--- /dev/null
@@ -0,0 +1,57 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# 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.
+
+import kernel
+
+class Foo
+       var a1: nullable Object = fa1 is lazy
+       var a2: nullable Object = fa2 is lazy
+       fun fa1: nullable Object do
+               1.output
+               return 10
+       end
+       fun fa2: nullable Object do
+               2.output
+               return 20
+       end
+end
+
+fun o(o: nullable Object)
+do
+       if o == null then
+               'n'.output
+               '\n'.output
+       else
+               o.output
+       end
+end
+
+var f = new Foo
+o f.a1
+o f.a1
+o f.a2
+o f.a2
+'\n'.output
+
+var g = new Foo
+o g.a2
+o g.a1
+o g.a2
+o g.a1
+'\n'.output
+
+var h = new Foo
+h.a1 = 100
+h.a1.output
+h.a1.output
diff --git a/tests/base_attr_named_setters.nit b/tests/base_attr_named_setters.nit
new file mode 100644 (file)
index 0000000..136c740
--- /dev/null
@@ -0,0 +1,67 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# 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.
+
+import kernel
+
+class A
+       fun foo: Int do return 1
+       fun set_bar(i: Int) do i.output
+       fun baz: Int do return 4
+       fun set_baz(i: Int) do i.output
+       fun zz do end
+end
+
+class B
+       super A
+       redef var foo: Int = 20 is writable(set_foo)
+       var bar: Int = 30 is redef writable(set_bar)
+       redef var baz: Int = 40 is writable(set_baz)
+       #alt2#var z: Int is writable(set_baz)
+       #alt3#var z: Int is writable(zz)
+       #alt4#var z: Int is redef writable(zz)
+end
+
+class C
+       super B
+       fun foo=(i: Int) do set_foo(i)
+       fun bar=(i: Int) do set_bar(i)
+       fun baz=(i: Int) do set_baz(i)
+end
+
+var a = new A
+a.foo.output
+a.set_bar 2
+a.set_baz 3
+a.baz.output
+
+'\n'.output
+
+var b = new B
+b.set_foo 10
+#alt1#b.foo = 10
+b.foo.output
+b.set_bar 20
+b.bar.output
+b.set_baz 30
+b.baz.output
+
+'\n'.output
+
+var c = new C
+c.foo = 100
+c.foo.output
+c.bar = 200
+c.bar.output
+c.baz = 300
+c.baz.output
diff --git a/tests/base_attr_readonly.nit b/tests/base_attr_readonly.nit
new file mode 100644 (file)
index 0000000..7b6ef58
--- /dev/null
@@ -0,0 +1,29 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# 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.
+
+import kernel
+
+class Foo
+       var a1 = 1 is readonly
+       fun run
+       do
+               #alt1#a1 = 2
+               #alt2#_a1 = 3 #hack
+               a1.output
+       end
+       #alt3# var a2: Int is readonly
+end
+
+var f = new Foo
+f.run
diff --git a/tests/base_init_noinit.nit b/tests/base_init_noinit.nit
new file mode 100644 (file)
index 0000000..87de46e
--- /dev/null
@@ -0,0 +1,31 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# 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.
+
+import kernel
+
+class A
+       var x: Object is noinit #alt1,3# var x: Object
+       var y: Object is noinit #alt2,3# var y: Object
+       fun work
+       do
+               if isset _x then x.output
+               if isset _y then y.output
+               0.output
+       end
+       #alt5#var z: Object = 5 is noinit
+end
+
+var a: A
+a = new A#alt1#a = new A(2)#alt2#a = new A(30)#alt3#a = new A(4, 40)#alt4#a=new A(5)
+a.work
index 1adc321..f78b9b5 100644 (file)
@@ -18,24 +18,24 @@ class A
        protected fun proA(a: A) do end
        private fun priA(a: A) do end
 
-       var vpubA: nullable A writable
-       protected var vproA: nullable A protected writable
+       var vpubA: nullable A is writable
+       protected var vproA: nullable A is protected writable
        private var vpriA: nullable A
 
-       var vpubA2 writable = new A
-       protected var vproA2 protected writable = new A
+       var vpubA2 = new A is writable
+       protected var vproA2 = new A is protected writable
        private var vpriA2 = new A
 
        #alt1#fun pubB(a: B) do end
        #alt2#protected fun proB(a: B) do end
        private fun priB(a: B) do end
 
-       #alt3#var vpubB: nullable B writable
-       #alt4#protected var vproB: nullable B protected writable
+       #alt3#var vpubB: nullable B is writable
+       #alt4#protected var vproB: nullable B is protected writable
        private var vpriB: nullable B
 
-       #alt5#var vpubB2 writable = new B
-       #alt6#protected var vproB2 protected writable = new B
+       #alt5#var vpubB2 = new B is writable
+       #alt6#protected var vproB2 = new B is protected writable
        private var vpriB2 = new B
 
        init do end
@@ -46,24 +46,24 @@ private class B
        #alt7#protected fun proA(a: A) do end
        private fun priA(a: A) do end
 
-       var vpubA: nullable A writable
-       #alt7#protected var vproA: nullable A protected writable
+       var vpubA: nullable A is writable
+       #alt7#protected var vproA: nullable A is protected writable
        private var vpriA: nullable A
 
-       var vpubA2 writable = new A
-       #alt7#protected var vproA2 protected writable = new A
+       var vpubA2 = new A is writable
+       #alt7#protected var vproA2 = new A is protected writable
        private var vpriA2 = new A
 
        fun pubB(a: B) do end
        #alt7#protected fun proB(a: B) do end
        private fun priB(a: B) do end
 
-       var vpubB: nullable B writable
-       #alt7#protected var vproB: nullable B protected writable
+       var vpubB: nullable B is writable
+       #alt7#protected var vproB: nullable B is protected writable
        private var vpriB: nullable B
 
-       var vpubB2 writable = new B
-       #alt7#protected var vproB2 protected writable = new B
+       var vpubB2 = new B is writable
+       #alt7#protected var vproB2 = new B is protected writable
        private var vpriB2 = new B
 
        init do end
index 9009a88..89fff9e 100644 (file)
@@ -20,12 +20,12 @@ class C
        #alt2#protected fun proA(a: A) do end
        private fun priA(a: A) do end
 
-       #alt3#var vpubA: nullable A writable
-       #alt4#protected var vproA: nullable A protected writable
+       #alt3#var vpubA: nullable A is writable
+       #alt4#protected var vproA: nullable A is protected writable
        private var vpriA: nullable A
 
-       #alt5#var vpubA2 writable = new A
-       #alt6#protected var vproA2 protected writable = new A
+       #alt5#var vpubA2 = new A is writable
+       #alt6#protected var vproA2 = new A is protected writable
        private var vpriA2 = new A
 
        init do end
@@ -35,10 +35,10 @@ private class D
        fun pubA(a: A) do end
        private fun priA(a: A) do end
 
-       var vpubA: nullable A writable
+       var vpubA: nullable A is writable
        private var vpriA: nullable A
 
-       var vpubA2 writable = new A
+       var vpubA2 = new A is writable
        private var vpriA2 = new A
 
        init do end
index 2f2a73f..277cc6d 100644 (file)
@@ -19,7 +19,7 @@ import kernel
 class A
        type E: T
 
-       var e: nullable E writable = null
+       var e: nullable E = null is writable
 end
 
 class B
index af6da5c..5f86a26 100644 (file)
@@ -19,7 +19,7 @@ import kernel
 class A
        type E: T
        
-       var e: nullable E writable = null
+       var e: nullable E = null is writable
 end
 
 class B
index 6f66799..545092f 100644 (file)
@@ -19,7 +19,7 @@ import base_virtual_type2
 
 class C
        super A
-       var tab: nullable Array[E] writable
+       var tab: nullable Array[E] is writable
        init do end
 end
 
index 4d5ce65..07d5fda 100644 (file)
@@ -20,9 +20,9 @@ class G[E]
        type F: E
        type F2: F
 
-       var e: E writable
-       var f: F writable
-       var f2: F2 writable
+       var e: E is writable
+       var f: F is writable
+       var f2: F2 is writable
 
        init(e: E, f: F, f2: F2)
        do
index b4a79d0..76fd5dc 100644 (file)
@@ -19,7 +19,7 @@ import kernel
 class A
        type E: F
        type F: E
-       var e: nullable E writable = null
+       var e: nullable E = null is writable
        init do end
 end
 
diff --git a/tests/sav/base_attr_lazy.res b/tests/sav/base_attr_lazy.res
new file mode 100644 (file)
index 0000000..540f9b8
--- /dev/null
@@ -0,0 +1,16 @@
+1
+10
+10
+2
+20
+20
+
+2
+20
+1
+10
+20
+10
+
+100
+100
diff --git a/tests/sav/base_attr_lazy_alt1.res b/tests/sav/base_attr_lazy_alt1.res
new file mode 100644 (file)
index 0000000..d628b21
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_lazy_alt1.nit:28,20--23: Error: a lazy attribute needs a value
diff --git a/tests/sav/base_attr_lazy_int.res b/tests/sav/base_attr_lazy_int.res
new file mode 100644 (file)
index 0000000..540f9b8
--- /dev/null
@@ -0,0 +1,16 @@
+1
+10
+10
+2
+20
+20
+
+2
+20
+1
+10
+20
+10
+
+100
+100
diff --git a/tests/sav/base_attr_lazy_nullable.res b/tests/sav/base_attr_lazy_nullable.res
new file mode 100644 (file)
index 0000000..540f9b8
--- /dev/null
@@ -0,0 +1,16 @@
+1
+10
+10
+2
+20
+20
+
+2
+20
+1
+10
+20
+10
+
+100
+100
diff --git a/tests/sav/base_attr_named_setters.res b/tests/sav/base_attr_named_setters.res
new file mode 100644 (file)
index 0000000..9e263e5
--- /dev/null
@@ -0,0 +1,12 @@
+1
+2
+3
+4
+
+10
+20
+30
+
+100
+200
+300
diff --git a/tests/sav/base_attr_named_setters_alt1.res b/tests/sav/base_attr_named_setters_alt1.res
new file mode 100644 (file)
index 0000000..cf8d660
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_named_setters_alt1.nit:52,1--10: Error: Method 'foo=' doesn't exists in B.
diff --git a/tests/sav/base_attr_named_setters_alt2.res b/tests/sav/base_attr_named_setters_alt2.res
new file mode 100644 (file)
index 0000000..ada80a6
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_named_setters_alt2.nit:30,6: Error: A property set_baz is already defined in class B at line 29.
diff --git a/tests/sav/base_attr_named_setters_alt3.res b/tests/sav/base_attr_named_setters_alt3.res
new file mode 100644 (file)
index 0000000..ed64fb8
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_named_setters_alt3.nit:31,6: Redef error: B::zz is an inherited property. To redefine it, add the redef keyword.
diff --git a/tests/sav/base_attr_named_setters_alt4.res b/tests/sav/base_attr_named_setters_alt4.res
new file mode 100644 (file)
index 0000000..9409278
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_named_setters_alt4.nit:32,9--11: Redef Error: 1 parameters found, 0 expected. Signature is base_attr_named_setters_alt4#B#zz
diff --git a/tests/sav/base_attr_readonly.res b/tests/sav/base_attr_readonly.res
new file mode 100644 (file)
index 0000000..d00491f
--- /dev/null
@@ -0,0 +1 @@
+1
diff --git a/tests/sav/base_attr_readonly_alt1.res b/tests/sav/base_attr_readonly_alt1.res
new file mode 100644 (file)
index 0000000..7405b6f
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_readonly_alt1.nit:21,3--8: Error: Method or variable 'a1=' unknown in Foo.
diff --git a/tests/sav/base_attr_readonly_alt2.res b/tests/sav/base_attr_readonly_alt2.res
new file mode 100644 (file)
index 0000000..00750ed
--- /dev/null
@@ -0,0 +1 @@
+3
diff --git a/tests/sav/base_attr_readonly_alt3.res b/tests/sav/base_attr_readonly_alt3.res
new file mode 100644 (file)
index 0000000..5c34535
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_readonly_alt3.nit:25,17--24: Error: a readonly attribute needs a value
diff --git a/tests/sav/base_init_noinit.res b/tests/sav/base_init_noinit.res
new file mode 100644 (file)
index 0000000..573541a
--- /dev/null
@@ -0,0 +1 @@
+0
diff --git a/tests/sav/base_init_noinit_alt1.res b/tests/sav/base_init_noinit_alt1.res
new file mode 100644 (file)
index 0000000..389e262
--- /dev/null
@@ -0,0 +1,2 @@
+2
+0
diff --git a/tests/sav/base_init_noinit_alt2.res b/tests/sav/base_init_noinit_alt2.res
new file mode 100644 (file)
index 0000000..f4b9eda
--- /dev/null
@@ -0,0 +1,2 @@
+30
+0
diff --git a/tests/sav/base_init_noinit_alt3.res b/tests/sav/base_init_noinit_alt3.res
new file mode 100644 (file)
index 0000000..84cd911
--- /dev/null
@@ -0,0 +1,3 @@
+4
+40
+0
diff --git a/tests/sav/base_init_noinit_alt4.res b/tests/sav/base_init_noinit_alt4.res
new file mode 100644 (file)
index 0000000..0e9d1ef
--- /dev/null
@@ -0,0 +1 @@
+alt/base_init_noinit_alt4.nit:30,3--10: Error: Incorrect number of parameters. Got 1, expected 0. Signature is 
diff --git a/tests/sav/base_init_noinit_alt5.res b/tests/sav/base_init_noinit_alt5.res
new file mode 100644 (file)
index 0000000..b79ac75
--- /dev/null
@@ -0,0 +1 @@
+alt/base_init_noinit_alt5.nit:26,23--28: Error: `noinit` attributes cannot have an initial value
index 18547d4..a5c0088 100644 (file)
@@ -1,10 +1,10 @@
 alt/base_prot_sig_alt7.nit:46,2--10: Error: The only legal visibility for properties in a private class is private.
 alt/base_prot_sig_alt7.nit:50,2--10: Error: The only legal visibility for properties in a private class is private.
-alt/base_prot_sig_alt7.nit:50,34--42: Error: The only legal visibility for properties in a private class is private.
+alt/base_prot_sig_alt7.nit:50,37--45: Error: The only legal visibility for properties in a private class is private.
 alt/base_prot_sig_alt7.nit:54,2--10: Error: The only legal visibility for properties in a private class is private.
-alt/base_prot_sig_alt7.nit:54,23--31: Error: The only legal visibility for properties in a private class is private.
+alt/base_prot_sig_alt7.nit:54,34--42: Error: The only legal visibility for properties in a private class is private.
 alt/base_prot_sig_alt7.nit:58,2--10: Error: The only legal visibility for properties in a private class is private.
 alt/base_prot_sig_alt7.nit:62,2--10: Error: The only legal visibility for properties in a private class is private.
-alt/base_prot_sig_alt7.nit:62,34--42: Error: The only legal visibility for properties in a private class is private.
+alt/base_prot_sig_alt7.nit:62,37--45: Error: The only legal visibility for properties in a private class is private.
 alt/base_prot_sig_alt7.nit:66,2--10: Error: The only legal visibility for properties in a private class is private.
-alt/base_prot_sig_alt7.nit:66,23--31: Error: The only legal visibility for properties in a private class is private.
+alt/base_prot_sig_alt7.nit:66,34--42: Error: The only legal visibility for properties in a private class is private.
diff --git a/tests/sav/complete_simple_android.res b/tests/sav/complete_simple_android.res
new file mode 100644 (file)
index 0000000..174d681
--- /dev/null
@@ -0,0 +1 @@
+Not executable (platform?)
index 5c8e301..611c433 100644 (file)
@@ -1,2 +1,3 @@
-Usage: nitmetrics [OPTION]... <file.nit>...mComputes various metrics on Nit programs.
+Usage: nitmetrics [OPTION]... <file.nit>...
+Computes various metrics on Nit programs.
 Use --help for help
index e7376cd..a8087e1 100644 (file)
@@ -20,13 +20,12 @@ import json_serialization
 # Simple class
 class A
        auto_serializable
-       super Serializable
 
-       var b: Bool
+       var b = false
        var c: Char
        var f: Float
-       var i: Int
-       var s: String
+       var i = 123
+       var s = "asdf"
        var n: nullable Int
 
        init(b: Bool, c: Char, f: Float, i: Int, s: String, n: nullable Int)
@@ -63,10 +62,9 @@ end
 # Composed of an A and a B
 class C
        auto_serializable
-       super Serializable
 
        var a: A
-       var b: B
+       var b = new B(false, 'b', 123.123, 2345, "hjkl", 12, 1111, "qwer")
        var aa: A
 
        init(a: A, b: B)
index a7c057c..642abeb 100644 (file)
@@ -31,7 +31,7 @@ extern class JavaArrayList in "Java" `{ java.util.ArrayList `}
 
        redef fun output in "Java" `{
                for (Object i: recv) {
-                       System.out.println((int)i);
+                       System.out.println((long)i);
                }
        `}
 
index 24b69e2..cc99b1e 100644 (file)
@@ -33,8 +33,8 @@ end
 
 class Gen3[H: Int]
        super Gen1[H, Char]
-   redef var e: H redef writable
-   redef var f_: Char redef writable = 'N'
+   redef var e: H is redef writable
+   redef var f_: Char = 'N' is redef writable
    redef fun f: Char do return f_ end
    redef fun f=(x: Char) do f_ = x end
 
index b6a5bbc..59aac77 100644 (file)
@@ -20,15 +20,14 @@ import json_serialization
 # Simple class
 class A
        auto_serializable
-       super Serializable
 
-       var b: Bool
+       var b = false
        var c: Char
        var f: Float
-       var i: Int
-       var s: String
+       var i = 123
+       var s = "asdf"
        var n: nullable Int
-       var array: Array[nullable Object] = new Array[nullable Object].with_items(88, "hello", null)
+       var array = new Array[nullable Object].with_items(88, "hello", null)
 
        init(b: Bool, c: Char, f: Float, i: Int, s: String, n: nullable Int)
        do
@@ -64,10 +63,9 @@ end
 # Composed of an A and a B
 class C
        auto_serializable
-       super Serializable
 
        var a: A
-       var b: B
+       var b = new B(false, 'b', 123.123, 2345, "hjkl", 12, 1111, "qwer")
        var aa: A
 
        init(a: A, b: B)