From: Jean Privat Date: Mon, 28 Sep 2015 14:36:07 +0000 (-0400) Subject: Merge: Bytes is now Writable X-Git-Tag: v0.7.8~4 X-Git-Url: http://nitlanguage.org?hp=232f04e5700296bdc119d501640ad9e3707384bc Merge: Bytes is now Writable As @xymus requested, `Bytes` is now a subclass of `Writable` Pull-Request: #1738 Reviewed-by: Jean Privat Reviewed-by: Alexis Laferrière --- diff --git a/contrib/memory/Makefile b/contrib/memory/Makefile index 8e39e1d..ac91a73 100644 --- a/contrib/memory/Makefile +++ b/contrib/memory/Makefile @@ -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 diff --git a/contrib/memory/org.nitlanguage.memory.txt b/contrib/memory/org.nitlanguage.memory.txt index 1bef17b..77756da 100644 --- a/contrib/memory/org.nitlanguage.memory.txt +++ b/contrib/memory/org.nitlanguage.memory.txt @@ -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. diff --git a/contrib/memory/package.ini b/contrib/memory/package.ini index d271a73..9a79f36 100644 --- a/contrib/memory/package.ini +++ b/contrib/memory/package.ini @@ -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 diff --git a/contrib/memory/src/memory.nit b/contrib/memory/src/memory.nit index 3e9877d..e184b99 100644 --- a/contrib/memory/src/memory.nit +++ b/contrib/memory/src/memory.nit @@ -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 diff --git a/contrib/mnit_test/package.ini b/contrib/mnit_test/package.ini index adcdf8f..5247640 100644 --- a/contrib/mnit_test/package.ini +++ b/contrib/mnit_test/package.ini @@ -1,6 +1,6 @@ [package] name=mnit_test -tags= +tags=testing maintainer=Alexis Laferrière license=Apache-2.0 [upstream] diff --git a/contrib/nitcc/tests/package.ini b/contrib/nitcc/tests/packages.ini similarity index 100% rename from contrib/nitcc/tests/package.ini rename to contrib/nitcc/tests/packages.ini diff --git a/examples/draw_operation.ini b/examples/draw_operation.ini index 189e88d..4ae4096 100644 --- a/examples/draw_operation.ini +++ b/examples/draw_operation.ini @@ -1,6 +1,6 @@ [package] name=draw_operation -tags= +tags=example maintainer=Alexis Laferrière license=Apache-2.0 [upstream] diff --git a/examples/mnit_ballz/org.nitlanguage.ballz_android.txt b/examples/mnit_ballz/org.nitlanguage.ballz.txt similarity index 100% rename from examples/mnit_ballz/org.nitlanguage.ballz_android.txt rename to examples/mnit_ballz/org.nitlanguage.ballz.txt diff --git a/lib/gen_nit.ini b/lib/gen_nit.ini new file mode 100644 index 0000000..0f1530c --- /dev/null +++ b/lib/gen_nit.ini @@ -0,0 +1,11 @@ +[package] +name=gen_nit +tags=devel +maintainer=Alexis Laferrière +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 diff --git a/lib/ordered_tree.nit b/lib/ordered_tree.nit index 0b1d383..d1dde15 100644 --- a/lib/ordered_tree.nit +++ b/lib/ordered_tree.nit @@ -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 index 0000000..fb0ab2b --- /dev/null +++ b/lib/text_stat.ini @@ -0,0 +1,11 @@ +[package] +name=text_stat +tags=debug,lib +maintainer=Lucas Bajolet +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 diff --git a/src/loader.nit b/src/loader.nit index a59ccf0..a914b56 100644 --- a/src/loader.nit +++ b/src/loader.nit @@ -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 diff --git a/tests/sav/nitls_args1.res b/tests/sav/nitls_args1.res index 19b7801..eca970e 100644 --- a/tests/sav/nitls_args1.res +++ b/tests/sav/nitls_args1.res @@ -10,4 +10,3 @@ project1 (project1) `--subdir (project1/subdir) |--module4 (project1/subdir/module4.nit) `--module_0 (project1/subdir/module_0.nit) -project2 (project1/project2/project2.nit) diff --git a/tests/sav/nitls_args2.res b/tests/sav/nitls_args2.res index 19b7801..eca970e 100644 --- a/tests/sav/nitls_args2.res +++ b/tests/sav/nitls_args2.res @@ -10,4 +10,3 @@ project1 (project1) `--subdir (project1/subdir) |--module4 (project1/subdir/module4.nit) `--module_0 (project1/subdir/module_0.nit) -project2 (project1/project2/project2.nit) diff --git a/tests/sav/nitls_args4.res b/tests/sav/nitls_args4.res index a8b51a5..267bbdb 100644 --- a/tests/sav/nitls_args4.res +++ b/tests/sav/nitls_args4.res @@ -8,4 +8,3 @@ project1/subdir/module_0 (project1/subdir/module_0.nit) project1/module_01 (project1/module_01.nit) project1/module_02 (project1/module_02.nit) project1/project1 (project1/project1.nit) -project2/project2 (project1/project2/project2.nit)