nit.git
8 years agosepcomp: fix hardening related to the instantiation of dead types
Jean Privat [Tue, 26 May 2015 18:43:16 +0000 (14:43 -0400)]
sepcomp: fix hardening related to the instantiation of dead types

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agoMerge: Binary over network
Jean Privat [Tue, 26 May 2015 10:12:35 +0000 (06:12 -0400)]
Merge: Binary over network

Add services to write strings in binary streams and better support for binary in network modules.

Pull-Request: #1390
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agoMerge: nitx: finish migration to new nitdoc architecture
Jean Privat [Tue, 26 May 2015 10:12:01 +0000 (06:12 -0400)]
Merge: nitx: finish migration to new nitdoc architecture

`nitx` is now part of the `doc` group using the same architecture as `nitdoc`.

This PR also add two new features:
* locate calls to a MProperty
* search pieces of code

Fixes #262

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

8 years agoMerge: Nitiwiki next
Jean Privat [Tue, 26 May 2015 12:37:54 +0000 (08:37 -0400)]
Merge: Nitiwiki next

Some fixes for `nitiwiki`.

Preparing for nitlanguage.org migration from ikiwiki to nitiwiki.

Pull-Request: #1367
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>

8 years agoMerge: Apply serialization in calculator, a_star, more_collections, Couple and Container
Jean Privat [Tue, 26 May 2015 10:09:51 +0000 (06:09 -0400)]
Merge: Apply serialization in calculator, a_star, more_collections, Couple and Container

Use `auto_serialize` in the calculator example, and remove the old custom JSON serialization.

The `a_star` module needed special care and could not rely only on `auto_serialize`. This was to avoid serializing graphs as a deep tree, instead we serialize the nodes first, then the links and we rebuild the graph at deserialization.

Besides that, more collections support the serialization.

Pull-Request: #1364
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: File and Bytes
Jean Privat [Tue, 26 May 2015 10:09:33 +0000 (06:09 -0400)]
Merge: File and Bytes

A bit of a fix in the context of issues #1267 and #1262.

The bytes module has a `ByteBuffer` class, while it is still working with `Int` at the moment, when Nit correctly supports `Bytes`, we can change it to a real `ByteBuffer`

This class is highly recommended when working with byte streams and collections.

As such, file operations are related to this module since most of the operations are working on bytes, what they mean is up to the end-user to figure.

Pull-Request: #1309
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Reviewed-by: Ait younes Mehdi Adel <overpex@gmail.com>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/binary: intro read/write strings as blocks
Alexis Laferrière [Sun, 24 May 2015 17:24:33 +0000 (13:24 -0400)]
lib/binary: intro read/write strings as blocks

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/binary: intro services to read/write null terminated strings
Alexis Laferrière [Sun, 24 May 2015 17:24:10 +0000 (13:24 -0400)]
lib/binary: intro services to read/write null terminated strings

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/socket: fix `NativeSocket::write_byte`
Alexis Laferrière [Sun, 24 May 2015 17:26:46 +0000 (13:26 -0400)]
lib/socket: fix `NativeSocket::write_byte`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/libevent: implement `write_byte`
Alexis Laferrière [Sun, 24 May 2015 17:25:52 +0000 (13:25 -0400)]
lib/libevent: implement `write_byte`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/libevent: `Connection` subclass `Writer`
Alexis Laferrière [Sun, 24 May 2015 17:25:16 +0000 (13:25 -0400)]
lib/libevent: `Connection` subclass `Writer`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agodebugger: remove dependency to `nitx`
Alexandre Terrasa [Mon, 25 May 2015 15:23:50 +0000 (11:23 -0400)]
debugger: remove dependency to `nitx`

Since the debugger is broken, we will redo the nitx command when it will be fixed.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitiwiki: use `InlineDecorator` for markdown titles in TOC
Alexandre Terrasa [Thu, 21 May 2015 18:12:24 +0000 (14:12 -0400)]
nitiwiki: use `InlineDecorator` for markdown titles in TOC

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agomarkdown: add misc decorators
Alexandre Terrasa [Thu, 21 May 2015 18:11:44 +0000 (14:11 -0400)]
markdown: add misc decorators

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agoexamples/calculator: use serialization
Alexis Laferrière [Sun, 17 May 2015 01:58:24 +0000 (21:58 -0400)]
examples/calculator: use serialization

This becomes a good example of a normal extra simple use of the
`auto_serializable` with `app::data_store`.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/serialization: support serializing Couple and Container
Alexis Laferrière [Wed, 20 May 2015 11:46:01 +0000 (07:46 -0400)]
lib/serialization: support serializing Couple and Container

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/more_collections: update classes as serializable
Alexis Laferrière [Mon, 18 May 2015 18:38:51 +0000 (14:38 -0400)]
lib/more_collections: update classes as serializable

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/a_star: update `a_star` to be serializable
Alexis Laferrière [Mon, 18 May 2015 18:34:30 +0000 (14:34 -0400)]
lib/a_star: update `a_star` to be serializable

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoMerge: metrics: `--nullables` distinguishes safe and unsafe calls on `null`
Jean Privat [Sat, 23 May 2015 01:01:37 +0000 (21:01 -0400)]
Merge: metrics: `--nullables` distinguishes safe and unsafe calls on `null`

In reaction of recent updates on #394 I wanted to have some up-to-date numbers.

`nitmetrics --nullable` can count the sends on nullable receivers but safe and unsafe calls where merged. Note: safe calls on nullable are things like `x == null`, that is safe even if `x` is a nullable thing.
So this PR distinguishes safe and unsafe calls.

Some numbers:

~~~
nitmetrics --nullables ../lib ../src/nit*.nit
Total number of sends: 60262
Number of sends on a unsafe nullable receiver: 1750 (2.90%)
Number of sends on a safe nullable receiver: 2639 (4.37%)
~~~

Pull-Request: #1375
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agoMerge: model: introduce the bottom type
Jean Privat [Sat, 23 May 2015 01:01:31 +0000 (21:01 -0400)]
Merge: model: introduce the bottom type

An old branch that was on some disk that I forgot to PR.

While the bottom type is useless now, it should be useful on future PR.
Type theorists and lattice fanboys might like it.

Pull-Request: #1374
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: Markdown: some improvement and fixes
Jean Privat [Sat, 23 May 2015 01:01:25 +0000 (21:01 -0400)]
Merge: Markdown: some improvement and fixes

Misc modification to markdown lib to facilitate custon Markdown parsing from external tools.

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

8 years agoMerge: Missing a unboxing when compiling a call to `new NativeArray`
Jean Privat [Sat, 23 May 2015 01:01:18 +0000 (21:01 -0400)]
Merge: Missing a unboxing when compiling a call to `new NativeArray`

In the following code,

~~~nit
var i
i = 4
var na = new NativeArray[Object](i)
~~~

the declaration type of `i` is `nullable Object`, so the C-type of `i` is `val*` (and not `int`).
Therefore, in the `new NativeArray`, it should be unboxed because the C signature expect a `int`.

Pull-Request: #1365
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: lib/standard: reimplement `files` with light FFI
Jean Privat [Sat, 23 May 2015 01:01:14 +0000 (21:01 -0400)]
Merge: lib/standard: reimplement `files` with light FFI

So I can use it during the bootstrap (thanks #1323)

Pull-Request: #1363
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: Nit objects to plain JSON
Jean Privat [Sat, 23 May 2015 01:01:11 +0000 (21:01 -0400)]
Merge: Nit objects to plain JSON

Adds an option to write Nit objects to plain JSON in `JsonSerializer`, and the shortcut `Serializable::to_plain_json`. This format lacks the meta-data necessary for the full deserialization but it is easier to read for non-Nit programs and humans.

You can see an example in the doc of `json::serialization` and here, taken from the tests. The following class uses "complex" Nit data structures and serialize them to the closest available structure in JSON.

~~~nit
class G
auto_serializable

var hs = new HashSet[Int]
var s = new ArraySet[String]
var hm = new HashMap[String, Int]
var am = new ArrayMap[String, String]

init
do
hs.add -1
hs.add 0
s.add "one"
s.add "two"
hm["one"] = 1
hm["two"] = 2
am["three"] = "3"
am["four"] = "4"
end
end
var g = new G
g.to_plain_json # ...
~~~
~~~json
{"hs": [-1, 0], "s": ["one", "two"], "hm": {"one": 1, "two": 2}, "am": {"three": "3", "four": "4"}}
~~~

Of course, when writing to a file or in a socket, it is better to use `JsonSerializer` as the `to_plain_json` version uses a string.

Pull-Request: #1360
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agolib/standard: reimplement `files` with basic FFI (so can be used in bootstraped)
Jean Privat [Fri, 22 May 2015 19:25:56 +0000 (15:25 -0400)]
lib/standard: reimplement `files` with basic FFI (so can be used in bootstraped)

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agolib: Various fixes on lib with the new file and stream API
Lucas Bajolet [Thu, 21 May 2015 18:23:02 +0000 (14:23 -0400)]
lib: Various fixes on lib with the new file and stream API

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agolib/standard/stream: Doc fixes
Lucas Bajolet [Thu, 21 May 2015 14:49:20 +0000 (10:49 -0400)]
lib/standard/stream: Doc fixes

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agolib/standard: Updated stream and file to support byte-oriented manipulations
Lucas Bajolet [Thu, 21 May 2015 14:48:58 +0000 (10:48 -0400)]
lib/standard: Updated stream and file to support byte-oriented manipulations

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agotests: update sav/nitmetrics_args1.res
Jean Privat [Fri, 22 May 2015 19:14:00 +0000 (15:14 -0400)]
tests: update sav/nitmetrics_args1.res

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agonitx: update man page
Alexandre Terrasa [Mon, 4 May 2015 15:41:29 +0000 (11:41 -0400)]
nitx: update man page

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitx: introduce code search
Alexandre Terrasa [Mon, 4 May 2015 15:04:56 +0000 (11:04 -0400)]
nitx: introduce code search

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitx: introduce search calls to MProperty
Alexandre Terrasa [Mon, 4 May 2015 14:47:07 +0000 (10:47 -0400)]
nitx: introduce search calls to MProperty

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitx: redo search for MType in new calls
Alexandre Terrasa [Mon, 4 May 2015 14:46:36 +0000 (10:46 -0400)]
nitx: redo search for MType in new calls

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agometrics: `--nullables` distinguishes safe and unsafe calls on `null`
Jean Privat [Thu, 21 May 2015 23:39:22 +0000 (19:39 -0400)]
metrics: `--nullables` distinguishes safe and unsafe calls on `null`

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agomodel: introduce the bottom type
Jean Privat [Thu, 21 May 2015 23:28:48 +0000 (19:28 -0400)]
model: introduce the bottom type

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agolib/markdown: force write on current_buffer
Alexandre Terrasa [Thu, 14 May 2015 06:23:12 +0000 (02:23 -0400)]
lib/markdown: force write on current_buffer

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agolib/markdown: introduce markdown to markdown decorator
Alexandre Terrasa [Thu, 14 May 2015 01:31:20 +0000 (21:31 -0400)]
lib/markdown: introduce markdown to markdown decorator

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agolib/markdown: use virtual type to make subclassing easier
Alexandre Terrasa [Thu, 14 May 2015 01:30:24 +0000 (21:30 -0400)]
lib/markdown: use virtual type to make subclassing easier

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agolib/markdown: move wikilinks parsing to lib/markdown
Alexandre Terrasa [Thu, 21 May 2015 19:38:30 +0000 (15:38 -0400)]
lib/markdown: move wikilinks parsing to lib/markdown

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitx: redo search for MType in returns
Alexandre Terrasa [Mon, 4 May 2015 14:45:18 +0000 (10:45 -0400)]
nitx: redo search for MType in returns

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitx: redo search for MType in params
Alexandre Terrasa [Mon, 4 May 2015 14:44:48 +0000 (10:44 -0400)]
nitx: redo search for MType in params

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitx: introduce doc page search
Alexandre Terrasa [Mon, 4 May 2015 14:43:59 +0000 (10:43 -0400)]
nitx: introduce doc page search

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitx: update tests
Alexandre Terrasa [Mon, 4 May 2015 15:12:03 +0000 (11:12 -0400)]
nitx: update tests

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitx: migrate to new Nitdoc architecture
Alexandre Terrasa [Mon, 4 May 2015 14:42:18 +0000 (10:42 -0400)]
nitx: migrate to new Nitdoc architecture

Some features are still missing, will be redone in further commits.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitiwiki display error before crashing when a template got missing
Alexandre Terrasa [Thu, 21 May 2015 18:11:04 +0000 (14:11 -0400)]
nitiwiki display error before crashing when a template got missing

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitiwiki: add tests for markdown extension config
Alexandre Terrasa [Thu, 21 May 2015 18:10:37 +0000 (14:10 -0400)]
nitiwiki: add tests for markdown extension config

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agonitiwiki: allow user to change markdown extension
Alexandre Terrasa [Thu, 21 May 2015 18:09:54 +0000 (14:09 -0400)]
nitiwiki: allow user to change markdown extension

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agotests: extends test_new_native.nit with non C-int length
Jean Privat [Thu, 21 May 2015 14:32:12 +0000 (10:32 -0400)]
tests: extends test_new_native.nit with non C-int length

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agocompilers: missing argument unboxing with new nativearray
Jean Privat [Thu, 21 May 2015 14:31:25 +0000 (10:31 -0400)]
compilers: missing argument unboxing with new nativearray

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agoMerge: share/libgc: option to use a local version of the source pkgs
Jean Privat [Thu, 21 May 2015 00:32:38 +0000 (20:32 -0400)]
Merge: share/libgc: option to use a local version of the source pkgs

This is only for tests servers, and should not be of any use to the regular user who doesn't trash and reclone the Nit repo many times each day.

So on Pratchett, @privat , you could download both source packages in the home directory
and the script will use and reuse them instead of repeatedly downloading them. I can change the directory to whatever you prefer, maybe ~/Downloads? or ~/.cache?

It will save us from some false CI test failure, like in http://gresil.org/jenkins/job/CI_github/2648/, and we will stop spamming the server.

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

8 years agoMerge: Steps on iterations and ranges
Jean Privat [Thu, 21 May 2015 00:32:31 +0000 (20:32 -0400)]
Merge: Steps on iterations and ranges

A proposal to solve some things identified in #1339

This PR does 3 things:

* extends any Iterator to locally (`next_by`) or globally (`to_step`) advance with more than a single `next`
* add `Range.step` to have a generic bidirectional and stepable iterator

So now people can write

~~~nit
for i in [1..10].step(2) do print i # in order 1 3 5 7 9
for i in [10..1].step(-2) do print i # in reverse order 10 8 6 5 2
~~~

This is a neat (over?-) engineering. A maybe non-POLA thing is that empty ranges can still be iterated with a negative step.

~~~nit
assert [5..1].is_empty # but
assert [5..1].step(-2).to_a == [5,3,1]
~~~

Pull-Request: #1347
Reviewed-by: ArthurDelamare <arthur.delamare@viacesi.fr>
Reviewed-by: Etienne M. Gagnon <egagnon@j-meg.com>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Ait younes Mehdi Adel <overpex@gmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agoMerge: nitx: start migration to `doc_phases`
Jean Privat [Thu, 21 May 2015 00:32:21 +0000 (20:32 -0400)]
Merge: nitx: start migration to `doc_phases`

This PR introduces the base rendering services for doc in console.

This will be used in the next version of `nitx` to benefit fron the new nitdoc architecture.

Pull-Request: #1315

8 years agolib/json: add doc to serialization
Alexis Laferrière [Wed, 20 May 2015 12:38:49 +0000 (08:38 -0400)]
lib/json: add doc to serialization

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/json: adds `to_plain_json`
Alexis Laferrière [Wed, 20 May 2015 13:08:38 +0000 (09:08 -0400)]
lib/json: adds `to_plain_json`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/json: serialization private import static
Alexis Laferrière [Wed, 20 May 2015 12:39:18 +0000 (08:39 -0400)]
lib/json: serialization private import static

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agotests: test serializing plain JSON
Alexis Laferrière [Tue, 19 May 2015 15:54:41 +0000 (11:54 -0400)]
tests: test serializing plain JSON

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agotests: extract JSON logic from test_deserialization
Alexis Laferrière [Tue, 19 May 2015 17:36:37 +0000 (13:36 -0400)]
tests: extract JSON logic from test_deserialization

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/json: serialization can write plain JSON
Alexis Laferrière [Tue, 19 May 2015 21:54:17 +0000 (17:54 -0400)]
lib/json: serialization can write plain JSON

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/json: avoid using super-strings and stream directly instead
Alexis Laferrière [Mon, 18 May 2015 18:40:37 +0000 (14:40 -0400)]
lib/json: avoid using super-strings and stream directly instead

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/json: extract `StrictHashMap` from `json::serialization`
Alexis Laferrière [Tue, 19 May 2015 19:47:05 +0000 (15:47 -0400)]
lib/json: extract `StrictHashMap` from `json::serialization`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib & contrib: update users of json::serialization
Alexis Laferrière [Wed, 20 May 2015 17:14:45 +0000 (13:14 -0400)]
lib & contrib: update users of json::serialization

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/json: move `json_serialization` to `json::serialization`
Alexis Laferrière [Tue, 19 May 2015 14:15:42 +0000 (10:15 -0400)]
lib/json: move `json_serialization` to `json::serialization`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoexamples: use `Range::step` in rosettacode/loops_downward_for.nit
Jean Privat [Wed, 20 May 2015 15:46:27 +0000 (11:46 -0400)]
examples: use `Range::step` in rosettacode/loops_downward_for.nit

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agoMerge: Safe collection access
Jean Privat [Wed, 20 May 2015 00:30:31 +0000 (20:30 -0400)]
Merge: Safe collection access

A proposition to solve an old API issue related to covariance in collections (and fix #1353)

This PR updates the signatures of access methods in collections: `has`, `[]` and anything related that takes an `E` or a `K` in read-collections.
This make these classes covariant-safe.

Previously, the signature was to strictly accepts the bound, thus making the code unsafe but has the advantage to provide static hints

~~~nit
assert [1,2,3].has("Hello") # static error, expected int got string
~~~

But this behavior had issues because:

* unsafe code, but it is not because Nit *can* be unsafe that Nit *should* be unsafe.
* a perfect semantic answer is possible, eq returning false in the previous example. thus the existing behavior is not POLA

Because the philosophy of Nit is that static types should help the programmer without being annoying, this PR lift the constraint on parameters of all read access methods.

The semantic is now more aligned with the one of dynamically typed language where the behavior is decided by messages and not by the types of things.

This especially allows to use collections of thing when `==` does not implies the equality of static types (ex subclasses of Sequence).

~~~nit
var a = [1,2,3]
var l = new List[Int].from(a)
assert a == l # by the law of Sequence

var aa = [a]
assert aa.has(l) # before the PR, error; with the PR, true

var ma = new Map[Array[Int],String]
ma[a] = "hello"
assert ma.has_key(l) # before the PR, error; with the PR, true
~~~

Pull-Request: #1355
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agoMerge: Read/Write binary data
Jean Privat [Wed, 20 May 2015 00:30:25 +0000 (20:30 -0400)]
Merge: Read/Write binary data

The module `binary` adds services to `Writer` and `Reader` to read/write binary data.

The services offer different size for each kind of data. They can be used to save space on a stream or for compatibility with external programs. They use type names from C:
* `write_float` write a Nit `Float` on 32 bits, with loss of precision.
* `write_double` write a Nit `Float` on 64 bits.
* `write_int64` write a Nit `Int` on 64 bits, with usually no loss of data, but it may still happen per platform.
* `write_bool` and `write_bits` to write booleans as a byte.
* There's a TODO for other suggested methods.

The endianess of each stream is configurable.

I tried to avoid touching too much to the main stream code knowing that @R4PaSs is working on reading/writing bytes. The binary module will have to be updated when we have a `Byte` type. Also, all the others types of `Writer` must be modified to implement `write_byte`.

I'll use this to write a binary alternative to json_serialization.

Pull-Request: #1354
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agoMerge: Serialization support SimpleCollection and Map, also bug fixes
Jean Privat [Wed, 20 May 2015 00:30:22 +0000 (20:30 -0400)]
Merge: Serialization support SimpleCollection and Map, also bug fixes

This PR is the result of using Nit serialization to implement game saving/loading in WBTW.

Update the serialization to work with (or avoid) the new auto constructors.

Support serializing Sets and Maps.

The `is_same_serialized` fix a problem where two instances were wrongly serialized as being the same. Because it previously used a `HashMap` (and thus `==`), two different _empty_ arrays were serialized as one and resulted in a single object on deserialization.

Once this and #1348 are merge, I'll update the calculator example to use the serialization.

Pull-Request: #1352
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: location: introduce `from_string` constructor
Jean Privat [Wed, 20 May 2015 00:30:14 +0000 (20:30 -0400)]
Merge: location: introduce `from_string` constructor

Useful to build a Location from it's string representation.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

Pull-Request: #1351
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoMerge: lib/gtk: add `GtkEntry::input_purpose`
Jean Privat [Wed, 20 May 2015 00:30:08 +0000 (20:30 -0400)]
Merge: lib/gtk: add `GtkEntry::input_purpose`

I don't have any immediate use for this features but it was interesting to see what GTK had to offer in this regard.

Pull-Request: #1349
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agoMerge: Intro the portable UI of app.nit
Jean Privat [Wed, 20 May 2015 00:29:57 +0000 (20:29 -0400)]
Merge: Intro the portable UI of app.nit

This PR introduces a basic API to create UI applications portable between Android and GNU/Linux. Each implementation apply refinements to implement the API using platform-specific native controls, and GTK on GNU/Linux.

A few notes on the API logic (you will want to read the readme file too):

* All attached `AppComponents` instances receive the life-cycle annotations. This includes all controls and view. So a visible `Button` will be notified when the application pauses.

* All controls can be observed by other instances so that they are notified of input events. In the calculator example, we use this to implement the behavior on button press in the window logic.

This PR also updates to the calculator example to use only the portable UI.

The scope of the portable UI at this point is limited to views needed by the calculator example.
This is intentionnal to keep a small number of views while still tweaking the portable UI foundation.

TODO next:

* Complete the abstraction of some partially implemented features: balancing the size of views in a layout and limit what can be the top-level view within a window.
* iOS, OS X, OpenGL implementations of the portable UI.
* Add more views, and concrete examples to the portable UI.
* Deal with multiple distinct windows (there is a real problem on Android where each activity must have a distinct Java class.)
* Find and document the best way for the user to create custom portable views.

Pull-Request: #1348
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Ait younes Mehdi Adel <overpex@gmail.com>

8 years agoMerge: nitdoc: display constructors list in MClass page
Jean Privat [Wed, 20 May 2015 00:29:52 +0000 (20:29 -0400)]
Merge: nitdoc: display constructors list in MClass page

Nitdoc now displays a list of available constructors for a class.

Fixes #875
Fixes #1195

Demos from [Jenkins::CI-nitdoc](http://gresil.org/jenkins/job/CI-nitdoc):
* [Standard library](http://gresil.org/jenkins/job/CI-nitdoc/ws/doc/stdlib/index.html)
* [Nit compilers and tools](http://gresil.org/jenkins/job/CI-nitdoc/ws/doc/nitc/index.html)

Pull-Request: #1341
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agonitdoc: assert valid key in redefinition of `provide_default_value`
Jean Privat [Tue, 19 May 2015 20:00:11 +0000 (16:00 -0400)]
nitdoc: assert valid key in redefinition of `provide_default_value`

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agotests: add test_coll_eq
Jean Privat [Tue, 19 May 2015 16:09:32 +0000 (12:09 -0400)]
tests: add test_coll_eq

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agolib: fix getters in subclasses of collection
Jean Privat [Tue, 19 May 2015 23:41:20 +0000 (19:41 -0400)]
lib: fix getters in subclasses of collection

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agolib/standard/collection: check the item can be compared in `Range#has`
Jean Privat [Tue, 19 May 2015 14:54:49 +0000 (10:54 -0400)]
lib/standard/collection: check the item can be compared in `Range#has`

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agolib/standard/collection: getter methods accepts `nullable Object` instead of a covari...
Jean Privat [Tue, 19 May 2015 14:52:38 +0000 (10:52 -0400)]
lib/standard/collection: getter methods accepts `nullable Object` instead of a covariant parameter

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agolib: remove superfluous type declaration in signatures
Jean Privat [Tue, 19 May 2015 14:49:42 +0000 (10:49 -0400)]
lib: remove superfluous type declaration in signatures

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agoshare/libgc: add a feature to script to use a local version of the source pkgs
Alexis Laferrière [Tue, 19 May 2015 23:01:18 +0000 (19:01 -0400)]
share/libgc: add a feature to script to use a local version of the source pkgs

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoexamples/calculator: gitignore the generated res folder
Alexis Laferrière [Tue, 19 May 2015 22:08:16 +0000 (18:08 -0400)]
examples/calculator: gitignore the generated res folder

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agotests: update sav for nitserial with types used in json_serialization
Alexis Laferrière [Mon, 18 May 2015 10:58:53 +0000 (06:58 -0400)]
tests: update sav for nitserial with types used in json_serialization

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agotests: fix sav with the correct behavior brought by `is_same_serialized`
Alexis Laferrière [Sun, 17 May 2015 18:13:04 +0000 (14:13 -0400)]
tests: fix sav with the correct behavior brought by `is_same_serialized`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agotests: add a serialization test with a `Set` and a `Map`
Alexis Laferrière [Sun, 17 May 2015 01:59:40 +0000 (21:59 -0400)]
tests: add a serialization test with a `Set` and a `Map`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/bucketed_game: make Game related classes serializable
Alexis Laferrière [Sun, 17 May 2015 13:08:15 +0000 (09:08 -0400)]
lib/bucketed_game: make Game related classes serializable

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/json_serialization: implement `SimpleCollection` and `Map`
Alexis Laferrière [Sun, 17 May 2015 13:19:25 +0000 (09:19 -0400)]
lib/json_serialization: implement `SimpleCollection` and `Map`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/json_serialization: extract `serialize_to_pure_json` from `Array`
Alexis Laferrière [Sun, 17 May 2015 01:54:17 +0000 (21:54 -0400)]
lib/json_serialization: extract `serialize_to_pure_json` from `Array`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/serialization: `SimpleCollection` and `Map` are `Serializable`
Alexis Laferrière [Sun, 17 May 2015 01:57:32 +0000 (21:57 -0400)]
lib/serialization: `SimpleCollection` and `Map` are `Serializable`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agostandard/collection: add `Range::step` to get a bidirectional stepped iterator
Jean Privat [Fri, 15 May 2015 19:20:35 +0000 (15:20 -0400)]
standard/collection: add `Range::step` to get a bidirectional stepped iterator

Signed-off-by: Jean Privat <jean@pryen.org>

8 years agolib/android: update `ui_test` to the new Android UI
Alexis Laferrière [Tue, 12 May 2015 20:31:36 +0000 (16:31 -0400)]
lib/android: update `ui_test` to the new Android UI

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib: update README of android and app
Alexis Laferrière [Sat, 9 May 2015 18:30:59 +0000 (14:30 -0400)]
lib: update README of android and app

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoexamples/calculator: update the format of the results expected by tests
Alexis Laferrière [Fri, 15 May 2015 17:09:08 +0000 (13:09 -0400)]
examples/calculator: update the format of the results expected by tests

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoexamples/calculator: update Makefile
Alexis Laferrière [Mon, 11 May 2015 13:09:06 +0000 (09:09 -0400)]
examples/calculator: update Makefile

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoexamples/calculator: remove the old platform specific implementations
Alexis Laferrière [Fri, 8 May 2015 19:43:41 +0000 (15:43 -0400)]
examples/calculator: remove the old platform specific implementations

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoexamples/calculator: implement state saving and loading
Alexis Laferrière [Fri, 8 May 2015 16:30:42 +0000 (12:30 -0400)]
examples/calculator: implement state saving and loading

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoexamples/calculator: intro the calculator abstract UI
Alexis Laferrière [Mon, 4 May 2015 19:25:14 +0000 (15:25 -0400)]
examples/calculator: intro the calculator abstract UI

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/linux: intro Linux implementation for app.nit UI using GTK
Alexis Laferrière [Tue, 5 May 2015 09:35:45 +0000 (05:35 -0400)]
lib/linux: intro Linux implementation for app.nit UI using GTK

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/gtk: fix missing 'h' in `GtkBox::omogeneous`
Alexis Laferrière [Tue, 19 May 2015 16:39:30 +0000 (12:39 -0400)]
lib/gtk: fix missing 'h' in `GtkBox::omogeneous`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agotests: test the binary reading and writing
Alexis Laferrière [Tue, 19 May 2015 01:07:20 +0000 (21:07 -0400)]
tests: test the binary reading and writing

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/binary: intro services to read/write binary data (partial API)
Alexis Laferrière [Mon, 18 May 2015 22:01:34 +0000 (18:01 -0400)]
lib/binary: intro services to read/write binary data (partial API)

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/socket: implement `write_byte` in `TCPStream`
Alexis Laferrière [Tue, 19 May 2015 02:26:49 +0000 (22:26 -0400)]
lib/socket: implement `write_byte` in `TCPStream`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib: intro `Writer::write_byte` and implement it in `FileWriter`
Alexis Laferrière [Tue, 19 May 2015 02:28:19 +0000 (22:28 -0400)]
lib: intro `Writer::write_byte` and implement it in `FileWriter`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/json_serialization: don't register objects more than once
Alexis Laferrière [Sat, 16 May 2015 14:20:51 +0000 (10:20 -0400)]
lib/json_serialization: don't register objects more than once

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>