Merge: Bytes is now Writable
authorJean Privat <jean@pryen.org>
Mon, 28 Sep 2015 14:36:07 +0000 (10:36 -0400)
committerJean Privat <jean@pryen.org>
Mon, 28 Sep 2015 14:36:07 +0000 (10:36 -0400)
As @xymus requested, `Bytes` is now a subclass of `Writable`

Pull-Request: #1738
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

15 files changed:
contrib/memory/Makefile
contrib/memory/org.nitlanguage.memory.txt
contrib/memory/package.ini
contrib/memory/src/memory.nit
contrib/mnit_test/package.ini
contrib/nitcc/tests/packages.ini [moved from contrib/nitcc/tests/package.ini with 100% similarity]
examples/draw_operation.ini
examples/mnit_ballz/org.nitlanguage.ballz.txt [moved from examples/mnit_ballz/org.nitlanguage.ballz_android.txt with 100% similarity]
lib/gen_nit.ini [new file with mode: 0644]
lib/ordered_tree.nit
lib/text_stat.ini [new file with mode: 0644]
src/loader.nit
tests/sav/nitls_args1.res
tests/sav/nitls_args2.res
tests/sav/nitls_args4.res

index 8e39e1d..ac91a73 100644 (file)
@@ -33,4 +33,4 @@ bin/memory.apk: assets/images/drawing.png src/*.nit res/drawable-ldpi/icon.png
 
 android-release: assets/images/drawing.png src/*.nit res/drawable-ldpi/icon.png
        mkdir -p bin
-       ../../bin/nitc -o bin/memory.apk src/memory.nit -m ../../lib/mnit/android/android.nit -m ../../lib/android/  landscape.nit  --release
+       ../../bin/nitc -o bin/memory.apk src/memory.nit -m ../../lib/mnit/android/android.nit -m ../../lib/android/landscape.nit  --release
index 1bef17b..77756da 100644 (file)
@@ -4,7 +4,7 @@ Web Site:http://nitlanguage.org
 Source Code:http://nitlanguage.org/nit.git/tree/HEAD:/contrib/memory
 Issue Tracker:https://github.com/nitlang/nit/issues
 
-Summary: memory-based game using shapes and colors
+Summary:memory-based game using shapes and colors
 Description:
 A memory-based game where figures are cliqued in sequence by the computer and should be replayed by the player in the same order.
 As the player progresses, more figures are added and the sequences to remember become longer.
index d271a73..9a79f36 100644 (file)
@@ -9,3 +9,4 @@ git=https://github.com/nitlang/nit.git
 git.directory=contrib/memory/
 homepage=http://nitlanguage.org
 issues=https://github.com/nitlang/nit/issues
+apk=http://nitlanguage.org/fdroid/apk/memory.apk
index 3e9877d..e184b99 100644 (file)
@@ -27,6 +27,7 @@
 # * Crappy UI element placement
 module memory is
        app_name("Memorize Shapes and Colors")
+       app_namespace "org.nitlanguage.memory"
        app_version(0, 1, git_revision)
 end
 
index adcdf8f..5247640 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name=mnit_test
-tags=
+tags=testing
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 license=Apache-2.0
 [upstream]
index 189e88d..4ae4096 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name=draw_operation
-tags=
+tags=example
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 license=Apache-2.0
 [upstream]
diff --git a/lib/gen_nit.ini b/lib/gen_nit.ini
new file mode 100644 (file)
index 0000000..0f1530c
--- /dev/null
@@ -0,0 +1,11 @@
+[package]
+name=gen_nit
+tags=devel
+maintainer=Alexis Laferrière <alexis.laf@xymus.net>
+license=Apache-2.0
+[upstream]
+browse=https://github.com/nitlang/nit/tree/master/lib/gen_nit.nit
+git=https://github.com/nitlang/nit.git
+git.directory=lib/gen_nit.nit
+homepage=http://nitlanguage.org
+issues=https://github.com/nitlang/nit/issues
index 0b1d383..d1dde15 100644 (file)
@@ -128,7 +128,15 @@ class OrderedTree[E: Object]
        do
                var old_parent = parents.get_or_null(e)
                if old_parent != null then
-                       sub[old_parent].remove(e)
+                       var subs = sub[old_parent]
+                       subs.remove(e)
+                       if subs.is_empty then
+                               # remove the sub when all children are detached
+                               # so that `==` and `hash` are sane
+                               # Otherwise an empty array will be considered
+                               # differently than no array.
+                               sub.keys.remove(old_parent)
+                       end
                else if roots.has(e) then
                        roots.remove(e)
                end
@@ -149,6 +157,7 @@ class OrderedTree[E: Object]
        do
                if not sub.has_key(e) then return
                var subs = sub[e]
+               if subs.is_empty then return
                var last = subs.last
                for e2 in subs do
                        if e2 != last then
diff --git a/lib/text_stat.ini b/lib/text_stat.ini
new file mode 100644 (file)
index 0000000..fb0ab2b
--- /dev/null
@@ -0,0 +1,11 @@
+[package]
+name=text_stat
+tags=debug,lib
+maintainer=Lucas Bajolet <r4pass@hotmail.com>
+license=Apache-2.0
+[upstream]
+browse=https://github.com/nitlang/nit/tree/master/lib/text_stat.nit
+git=https://github.com/nitlang/nit.git
+git.directory=lib/text_stat.nit
+homepage=http://nitlanguage.org
+issues=https://github.com/nitlang/nit/issues
index a59ccf0..a914b56 100644 (file)
@@ -323,7 +323,7 @@ redef class ModelBuilder
        fun identify_file(path: String): nullable ModulePath
        do
                # special case for not a nit file
-               if path.file_extension != "nit" then
+               if not path.has_suffix(".nit") then
                        # search dirless files in known -I paths
                        if not path.chars.has('/') then
                                var res = search_module_in_paths(null, path, self.paths)
@@ -352,10 +352,12 @@ redef class ModelBuilder
                end
 
                # Fast track, the path is already known
-               var pn = path.basename(".nit")
+               if identified_files_by_path.has_key(path) then return identified_files_by_path[path]
                var rp = module_absolute_path(path)
                if identified_files_by_path.has_key(rp) then return identified_files_by_path[rp]
 
+               var pn = path.basename(".nit")
+
                # Search for a group
                var mgrouppath = path.join_path("..").simplify_path
                var mgroup = get_mgroup(mgrouppath)
@@ -380,6 +382,7 @@ redef class ModelBuilder
                mgroup.module_paths.add(res)
 
                identified_files_by_path[rp] = res
+               identified_files_by_path[path] = res
                identified_files.add(res)
                return res
        end
@@ -393,10 +396,15 @@ redef class ModelBuilder
        # Note: `paths` is also used to look for mgroups
        fun get_mgroup(dirpath: String): nullable MGroup
        do
-               if not dirpath.file_exists then do
+               var stat = dirpath.file_stat
+
+               if stat == null then do
+                       # search dirless directories in known -I paths
+                       if dirpath.chars.has('/') then return null
                        for p in paths do
                                var try = p / dirpath
-                               if try.file_exists then
+                               stat = try.file_stat
+                               if stat != null then
                                        dirpath = try
                                        break label
                                end
@@ -404,20 +412,19 @@ redef class ModelBuilder
                        return null
                end label
 
+               # Filter out non-directories
+               if not stat.is_dir then
+                       return null
+               end
+
+               # Fast track, the path is already known
                var rdp = module_absolute_path(dirpath)
                if mgroups.has_key(rdp) then
                        return mgroups[rdp]
                end
 
-               # Filter out non-directories
-               var stat = dirpath.file_stat
-               if stat == null or not stat.is_dir then
-                       mgroups[rdp] = null
-                       return null
-               end
-
                # By default, the name of the package or group is the base_name of the directory
-               var pn = rdp.basename(".nit")
+               var pn = rdp.basename
 
                # Check `package.ini` that indicate a package
                var ini = null
@@ -525,23 +532,24 @@ redef class ModelBuilder
                        var fp = p/f
                        var g = get_mgroup(fp)
                        # Recursively scan for groups of the same package
-                       if g != null and g.mpackage == mgroup.mpackage then
+                       if g == null then
+                               identify_file(fp)
+                       else if g.mpackage == mgroup.mpackage then
                                scan_group(g)
                        end
-                       identify_file(fp)
                end
        end
 
        # Transform relative paths (starting with '../') into absolute paths
        private fun module_absolute_path(path: String): String do
-               return getcwd.join_path(path).simplify_path
+               return path.realpath
        end
 
        # Try to load a module AST using a path.
        # Display an error if there is a problem (IO / lexer / parser) and return null
        fun load_module_ast(filename: String): nullable AModule
        do
-               if filename.file_extension != "nit" then
+               if not filename.has_suffix(".nit") then
                        self.toolcontext.error(null, "Error: file `{filename}` is not a valid nit module.")
                        return null
                end
index 19b7801..eca970e 100644 (file)
@@ -10,4 +10,3 @@ project1 (\e[33mproject1\e[m)
 `--subdir (\e[33mproject1/subdir\e[m)
    |--\e[1mmodule4\e[m (\e[33mproject1/subdir/module4.nit\e[m)
    `--\e[1mmodule_0\e[m (\e[33mproject1/subdir/module_0.nit\e[m)
-\e[1mproject2\e[m (\e[33mproject1/project2/project2.nit\e[m)
index 19b7801..eca970e 100644 (file)
@@ -10,4 +10,3 @@ project1 (\e[33mproject1\e[m)
 `--subdir (\e[33mproject1/subdir\e[m)
    |--\e[1mmodule4\e[m (\e[33mproject1/subdir/module4.nit\e[m)
    `--\e[1mmodule_0\e[m (\e[33mproject1/subdir/module_0.nit\e[m)
-\e[1mproject2\e[m (\e[33mproject1/project2/project2.nit\e[m)
index a8b51a5..267bbdb 100644 (file)
@@ -8,4 +8,3 @@ project1/subdir/\e[1mmodule_0\e[m (\e[33mproject1/subdir/module_0.nit\e[m)
 project1/\e[1mmodule_01\e[m (\e[33mproject1/module_01.nit\e[m)
 project1/\e[1mmodule_02\e[m (\e[33mproject1/module_02.nit\e[m)
 project1/\e[1mproject1\e[m (\e[33mproject1/project1.nit\e[m)
-project2/\e[1mproject2\e[m (\e[33mproject1/project2/project2.nit\e[m)