nit.git
8 years agoRename REAMDE to README.md
Jean Privat [Tue, 26 May 2015 17:52:49 +0000 (13:52 -0400)]
Rename REAMDE to README.md

And a small whitespace fix

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 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>

8 years agolib/json_serialization: intro and use a map based on is_same_serialized
Alexis Laferrière [Sun, 17 May 2015 16:04:21 +0000 (12:04 -0400)]
lib/json_serialization: intro and use a map based on is_same_serialized

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

8 years agolib/serialization: intro `is_same_serialized`
Alexis Laferrière [Sat, 16 May 2015 18:38:22 +0000 (14:38 -0400)]
lib/serialization: intro `is_same_serialized`

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

8 years agolib/standard: fix a repeated error in the kernel module doc
Alexis Laferrière [Sun, 17 May 2015 16:04:48 +0000 (12:04 -0400)]
lib/standard: fix a repeated error in the kernel module doc

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

8 years agosrc/serialization: do generate constructor for abstract classes
Alexis Laferrière [Sat, 16 May 2015 19:28:09 +0000 (15:28 -0400)]
src/serialization: do generate constructor for abstract classes

Reverts an invalid part of 7b410ca.

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

8 years agoserialization: better error messages for debugging serialization engines
Alexis Laferrière [Sat, 16 May 2015 18:40:31 +0000 (14:40 -0400)]
serialization: better error messages for debugging serialization engines

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

8 years agoserialization: use an inherited constructor
Alexis Laferrière [Sat, 16 May 2015 14:21:04 +0000 (10:21 -0400)]
serialization: use an inherited constructor

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

8 years agoneo: use `Location.from_string`
Alexandre Terrasa [Sat, 16 May 2015 02:37:56 +0000 (22:37 -0400)]
neo: use `Location.from_string`

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

8 years agolocation: introduce `from_string` constructor to compose a location from its String...
Alexandre Terrasa [Sat, 16 May 2015 02:35:45 +0000 (22:35 -0400)]
location: introduce `from_string` constructor to compose a location from its String representation

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

8 years agonitdoc: display constructors list in MClass page
Alexandre Terrasa [Fri, 15 May 2015 20:16:30 +0000 (16:16 -0400)]
nitdoc: display constructors list in MClass page

Fixes #875
Fixes #1195

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

8 years agostandard/collection: add `to_step` as a decorator of iterators
Jean Privat [Fri, 15 May 2015 01:15:07 +0000 (21:15 -0400)]
standard/collection: add `to_step` as a decorator of iterators

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

8 years agostandard/collection: add `Iterator::next_by` as a safe multiple `next`
Jean Privat [Fri, 15 May 2015 01:14:05 +0000 (21:14 -0400)]
standard/collection: add `Iterator::next_by` as a safe multiple `next`

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

8 years agolib/gtk: add `GtkEntry::input_purpose`
Alexis Laferrière [Sat, 9 May 2015 01:07:37 +0000 (21:07 -0400)]
lib/gtk: add `GtkEntry::input_purpose`

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

8 years agolib/android: revamp `android::ui` to implement `app::ui`
Alexis Laferrière [Tue, 12 May 2015 22:01:22 +0000 (18:01 -0400)]
lib/android: revamp `android::ui` to implement `app::ui`

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

8 years agolib/app: intro app.nit abstract UI API
Alexis Laferrière [Tue, 12 May 2015 13:27:09 +0000 (09:27 -0400)]
lib/app: intro app.nit abstract UI API

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

8 years agoMerge: Separate Erasure Compiler bugfix
Jean Privat [Thu, 14 May 2015 23:36:56 +0000 (19:36 -0400)]
Merge: Separate Erasure Compiler bugfix

In commit [12aa160](https://github.com/privat/nit/commit/12aa16093122a9f55976585b76b01869d6899634) by @xymus, the signature of a BOX was updated to the ctype_extern, i.e. void\* for all pointers.

The callsite was modified to ctype_extern in separate compiler but was not updated in separate erasure compiler.

This caused a bug in #1309 when NativeString was introduced in BufferedStream as the buffer, since the callsite and signature were defined with different signatures, the prototype with void\*, the implementation with char\*.

This PR fixes the bug by setting both to void\* as in separate compiler.

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

8 years agoMerge: Intro AppComponent to notify all elements of an app of its life cycle
Jean Privat [Thu, 14 May 2015 23:36:50 +0000 (19:36 -0400)]
Merge: Intro AppComponent to notify all elements of an app of its life cycle

The names of callbacks on the life cycle have been inspired by Android's. There is an equivalent to each of them in iOS, their naming is more precise but more complicated, so they looked less nity.

As of now, only `App` specialize `AppComponent`, but more users in the UI module will soon be introduced.

The implementation of this life cycle in mnit and the old Android implementation using the NDK is a bit awkward. But you will notice that it is much better in the newer NitActivity based implementation, which is the future!

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

8 years agoMerge: Fix nitunit for `String::format`
Jean Privat [Thu, 14 May 2015 23:36:39 +0000 (19:36 -0400)]
Merge: Fix nitunit for `String::format`

Since the code block was badly indented, it was not tested by `nitunit`.

Once the indentation was corrected, `nitunit` found that the test was failing.

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

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

8 years agoMerge: Bytes
Jean Privat [Thu, 14 May 2015 23:36:31 +0000 (19:36 -0400)]
Merge: Bytes

Added a module for basic handling of bytes at the lib level, a structure analogue to a FlatBuffer is proposed here to handle single-byte modification and appending.

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

8 years agoMerge: Read char
Jean Privat [Thu, 14 May 2015 23:35:54 +0000 (19:35 -0400)]
Merge: Read char

Semantics have been changed, before this PR, read_char was used to read a single byte and return -1 if EOF or timeout.

Since a Byte can have a value of -1, it is changed here:

* `read_char` now returns a Char (which, for the moment, is a byte, but this will change once UTF-8 is properly supported), and returns null on EOF or timeout
* `read_byte` has more or less the semantics of the old read_char, but returns null on EOF instead of -1 for the reasons mentioned earlier which could induce a wrong assumption about the state of the Stream

Edit: Still related to #1309

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

8 years agosrc/compiler: Fixed a bug introduced in 12aa1609, erasure compiler was not updated...
Lucas Bajolet [Thu, 14 May 2015 14:34:58 +0000 (10:34 -0400)]
src/compiler: Fixed a bug introduced in 12aa1609, erasure compiler was not updated at the time

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

8 years agolib/standard: Added bytes module for byte-oriented manipulations
Lucas Bajolet [Thu, 14 May 2015 13:33:29 +0000 (09:33 -0400)]
lib/standard: Added bytes module for byte-oriented manipulations

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

8 years agolib/android: `audio` still depends on the old `native_app_glue`
Alexis Laferrière [Thu, 14 May 2015 12:23:35 +0000 (08:23 -0400)]
lib/android: `audio` still depends on the old `native_app_glue`

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

8 years agolib/android: `nit_activity` implement the new app.nit life-cycle
Alexis Laferrière [Tue, 5 May 2015 20:32:07 +0000 (16:32 -0400)]
lib/android: `nit_activity` implement the new app.nit life-cycle

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

8 years agoexamples: update all users of mnit to the new life-cycle
Alexis Laferrière [Tue, 12 May 2015 22:21:30 +0000 (18:21 -0400)]
examples: update all users of mnit to the new life-cycle

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

8 years agoMerge: More Rosetta Code
Jean Privat [Thu, 14 May 2015 12:52:41 +0000 (08:52 -0400)]
Merge: More Rosetta Code

Because it is and easy task.

note that `tree_traversal` is not as nice as it could be. Maybe a visitor (or generator) should be used instead.
Moreover, a lot of code could be removed if #1274 is solved.

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

8 years agoMerge: Copy to native
Jean Privat [Thu, 14 May 2015 12:52:38 +0000 (08:52 -0400)]
Merge: Copy to native

Added copy_to_native method in Text, also its optimized versions for subclasses

As a bonus (and because it simplified my task here), substrings now return FlatTexts only instead of simple Text.

The latter will permit the implementation of StringReader as BufferedReader later in an optimized way

Pull-Request: #1335
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agolib/mnit_linux: update linux mnit implementation to use the new life-cycle
Alexis Laferrière [Tue, 12 May 2015 22:20:27 +0000 (18:20 -0400)]
lib/mnit_linux: update linux mnit implementation to use the new life-cycle

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

8 years agolib: update the old NDK based android to use new lifecycle
Alexis Laferrière [Tue, 12 May 2015 22:20:02 +0000 (18:20 -0400)]
lib: update the old NDK based android to use new lifecycle

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

8 years agolib/app: intro `AppComponent` to react to application life-cycle in app.nit
Alexis Laferrière [Tue, 12 May 2015 12:56:05 +0000 (08:56 -0400)]
lib/app: intro `AppComponent` to react to application life-cycle in app.nit

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

8 years agolib/android: assets_and_resources need only `dalvik`
Alexis Laferrière [Tue, 12 May 2015 21:54:29 +0000 (17:54 -0400)]
lib/android: assets_and_resources need only `dalvik`

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

8 years agolib/standard/string: fix whitespaces
Alexandre Terrasa [Wed, 13 May 2015 23:28:28 +0000 (19:28 -0400)]
lib/standard/string: fix whitespaces

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

8 years agolib/standard/string: Fix nitunit of Text::format
Alexandre Terrasa [Wed, 13 May 2015 23:28:11 +0000 (19:28 -0400)]
lib/standard/string: Fix nitunit of Text::format

Since the code block was badly indented, it was not tested.
Once the indentation corrected, nitunit found that the test was failing.
So I corrected it.

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

8 years agonitdoc: introduce console rendering phase
Alexandre Terrasa [Mon, 4 May 2015 14:18:30 +0000 (10:18 -0400)]
nitdoc: introduce console rendering phase

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

8 years agonitdoc: introduce templates for console rendering
Alexandre Terrasa [Mon, 4 May 2015 14:33:09 +0000 (10:33 -0400)]
nitdoc: introduce templates for console rendering

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

8 years agonitdoc: introduce console rendering service for Model entities
Alexandre Terrasa [Mon, 4 May 2015 14:28:02 +0000 (10:28 -0400)]
nitdoc: introduce console rendering service for Model entities

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

8 years agonitdoc: introduce `depth` service for DocComposite
Alexandre Terrasa [Wed, 13 May 2015 23:08:45 +0000 (19:08 -0400)]
nitdoc: introduce `depth` service for DocComposite

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

8 years agoMerge: Kill PushBackReader
Jean Privat [Wed, 13 May 2015 17:56:03 +0000 (13:56 -0400)]
Merge: Kill PushBackReader

As part of the #1309 series, this is a first PR signaling the death of the PushBackReader, since its semantics were for the least, doubtful, and since its use was mainly for look-ahead parsers, it's been decided that a peek operation on BufferedReaders would be better.

Pull-Request: #1333
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agolib: Replaced uses of read_char by read_byte when applicable
Lucas Bajolet [Wed, 13 May 2015 15:22:02 +0000 (11:22 -0400)]
lib: Replaced uses of read_char by read_byte when applicable

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

8 years agoMerge: nitdoc: introduce tabbed view to hidde less important data
Jean Privat [Wed, 13 May 2015 15:20:36 +0000 (11:20 -0400)]
Merge: nitdoc: introduce tabbed view to hidde less important data

This PR introduce discrete tabs in the Nitdoc HTML output to hidde less important data like linearization tree, subclasses list etc.
This makes the main page more clean and readable.

Just pass the mouse over a definition to make the tab menu appear and select the details you want to see.
I also moved the source link here.

One can see the difference on [`Array[E]::SELF`](http://gresil.org/jenkins/job/CI-nitdoc/ws/doc/stdlib/class_standard__collection__array__Array.html#article:standard__collection__array__Array__SELF.definition). Notice the little burger menu on the right of the signature.

Démos:
* [stdlib](http://gresil.org/jenkins/job/CI-nitdoc/ws/doc/stdlib/index.html)
* [nitc](http://gresil.org/jenkins/job/CI-nitdoc/ws/doc/nitc/index.html)

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

8 years agoMerge: Revamp app.nit print_error and print_warning
Jean Privat [Wed, 13 May 2015 15:20:32 +0000 (11:20 -0400)]
Merge: Revamp app.nit print_error and print_warning

Should we move `print_error` to the standard library? It could be useful and specialized for many usages. Android redirects to logcat, PNaCl could redirect to the JavaScript console, and nitcorn could tee to console and a file.

All the current errors printed on `sys.stderr` are lost on Android. Redirecting the stream is not ideal as each call to `write` would use a new line on the Android log.

Pull-Request: #1329
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>

8 years agoMerge: Standardize the name of Android API level annotations
Jean Privat [Wed, 13 May 2015 15:20:28 +0000 (11:20 -0400)]
Merge: Standardize the name of Android API level annotations

Rename `min_api_version`, `max_api_version` and `target_api_version` to `android_api_min`, `android_api_max` and `android_api_target`. It fits better with the other `android_` annotations (as seen in `lib/android/aware.nit`) and with the `app_` annotations.

> Please ignore the first commit, it is from #1325.

Pull-Request: #1328
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>

8 years agorosettacode: add 10 tasks (mainly loops)
Jean Privat [Wed, 13 May 2015 15:02:45 +0000 (11:02 -0400)]
rosettacode: add 10 tasks (mainly loops)

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

8 years agolib/standard/string: Added copy_to_native method to Text
Lucas Bajolet [Wed, 13 May 2015 14:59:18 +0000 (10:59 -0400)]
lib/standard/string: Added copy_to_native method to Text

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

8 years agolib/standard/strings: Substrings iterator now returns FlatTexts instead of Texts
Lucas Bajolet [Tue, 12 May 2015 18:10:15 +0000 (14:10 -0400)]
lib/standard/strings: Substrings iterator now returns FlatTexts instead of Texts

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

8 years agostandard: add `Range::reverse_iterator`
Jean Privat [Wed, 13 May 2015 14:54:07 +0000 (10:54 -0400)]
standard: add `Range::reverse_iterator`

Now people can write countdowns.

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

8 years agolib/standard: Removed push_back_reader and replaced it by a peek operation on Buffere...
Lucas Bajolet [Tue, 12 May 2015 15:42:25 +0000 (11:42 -0400)]
lib/standard: Removed push_back_reader and replaced it by a peek operation on BufferedReaders

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

8 years agolib/standard: Changed semantics of read_char and added read_byte for future uses
Lucas Bajolet [Tue, 12 May 2015 15:34:45 +0000 (11:34 -0400)]
lib/standard: Changed semantics of read_char and added read_byte for future uses

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

8 years agoMerge branch 'master' into android-annotations
Alexis Laferrière [Tue, 12 May 2015 12:44:45 +0000 (08:44 -0400)]
Merge branch 'master' into android-annotations

8 years agoMerge branch 'master' into print_error
Alexis Laferrière [Tue, 12 May 2015 12:43:19 +0000 (08:43 -0400)]
Merge branch 'master' into print_error

8 years agoMerge: Rosettacode grayscale implementation
Jean Privat [Mon, 11 May 2015 23:24:54 +0000 (19:24 -0400)]
Merge: Rosettacode grayscale implementation

An implementation of Rosettacode's grayscale task (http://rosettacode.org/wiki/Grayscale_image) with additional features, including creating a Bitmap from scratch and manipulating its individual pixels.

Pull-Request: #1282
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoMerge: Fix C compiler warning on Java FFI and Android apps
Jean Privat [Mon, 11 May 2015 23:22:55 +0000 (19:22 -0400)]
Merge: Fix C compiler warning on Java FFI and Android apps

The generated C code used `static JNIEXPORT`, when the macro was expanded it duplicated the visibility attribute. It was reported by the C compiler as a warning. This PR removes the `static` part.

Pull-Request: #1327
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>

8 years agoMerge: Clean up Android and Linux app.nit libraries
Jean Privat [Mon, 11 May 2015 23:22:48 +0000 (19:22 -0400)]
Merge: Clean up Android and Linux app.nit libraries

The prefix in `linux_data_store` and `android_data_store` is no longer needed.

Importing only `dalvik` from an Android module makes it compatible with both implementations: the newer nit_activity and the older native_app_glue still used by games.

Pull-Request: #1325
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>

8 years agoMerge: nit rpg ack
Jean Privat [Mon, 11 May 2015 23:22:40 +0000 (19:22 -0400)]
Merge: nit rpg ack

Consider :shipit: and :+1: to also be the acknowledgment of reviewers.

Pull-Request: #1324
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>

8 years agoMerge: Intro the light FFI and use it in nith
Jean Privat [Mon, 11 May 2015 23:22:31 +0000 (19:22 -0400)]
Merge: Intro the light FFI and use it in nith

The new light FFI use only features that should be easy to implement in new/alternative engines to quickly achieve a bootstrap. For this reason, core features of the Nit standard library should be limited to use the light FFI.

## Features of the light FFI

* **Extern methods** implemented in C, nested within the Nit code.
  The body of these method is copied directly to the generated C files for compilation.
  Also supports extern `new` factories.
* Module level **C code blocks**, both "C Body" (the default) and "C Header".
  They will be copied to the beginning of the generated C files.
* Automatic transformation of Nit **primitive types** from/to their equivalent in C.
* **Extern classes** to create a Nit class around a C pointer.
  Allows to specify the equivalent C type of the Nit extern class.

## Features of the full FFI

* More foreign languages: **C++, Java and Objective-C**.
* **Callbacks** to Nit from foreign codes.
  The callbacks are declared in Nit using the `import` annotation on extern methods.
  They are then generated on demand for the target foreign language.
* **Static Nit types** in C for precise typing and static typing errors in C.
* **Propagating public code blocks** at the module level (C Header).
  This allows to use extern classes in foreign code in other modules
  without having to import the related headers.
  This is optional in C as it is easy to find the correct importation.
  However it is important in Java and other complex FFIs.
* **Reference pinning** of Nit objects from foreign code.
  This ensure that objects referenced from foreign code are not liberated by the GC.
* FFI **annotations**:
    * `cflags`, `ldflags` and `cppflags` pass arguments to the C and C++
      compilers and linker.
    * `pkgconfig` calls the `pkg-config` program to get the arguments
      to pass to the C copiler and linker.
    * `extra_java_files` adds Java source file to the compilation chain.

## Light FFI only compilation

Compilers using the module `compiler_ffi::light_only` do not compile extern method with callbacks. This is a good heuristic to determine whether the method uses the full FFI of the light FFI.

The limitation of this heuristic is on 3 features: static Nit types, propagating public code blocks and reference pinning. These features do not required any declaration on the Nit side so they are not reliably detectable by the compiler. Using these features will cause GGC to raise errors on unfound types and functions.

In the case of public code block propagation, the user can fix it by importing the needed C headers in each module. In the other cases, static Nit types and reference pinning, they are used for callbacks, the method should probably declare callbacks. Still, there is some very rare situations where these features could be used correctly and the method would still be recognized as light FFI. If this is becomes a problem, we could add an annotation such as `is light_ffi` to force the heuristic.

> This PR should be read commit by commit. The first 4 commits separate modules in 2 their light/full versions. The only code modification is adding supers, redefs and tweaking the imports.

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

8 years agoMerge: nitiwiki: introduce wikilinks
Jean Privat [Mon, 11 May 2015 23:22:25 +0000 (19:22 -0400)]
Merge: nitiwiki: introduce wikilinks

Nitiwiki now understand the wikilink format using double brackets.

Examples:
`[[foo]]`: link to the page named `foo`
`[[foo/bar]]`: link to the page named `bar` in `foo`
`[[/foo/bar]]`: link to the page located exactly here

It's also possible to add a custom name:
`[[foo|My cute custom name <3]]`: link to the page named `foo`

And to use anchors:
`[[foo#bar]]`: link to the page named `foo`

nitiwiki will display warnings if a link seems broken.

Pull-Request: #1317
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoMerge: contrib: Introduce refund
Jean Privat [Mon, 11 May 2015 23:22:19 +0000 (19:22 -0400)]
Merge: contrib: Introduce refund

`refund` is a tool developped for the correction of the course INF2015: Développement de logiciels dans un environnement Agile.

Its purpose is to parse a reclamation sheet submitted by an insurrance client in Json format then to compute the allowed refunds depending on the policy contracted by the client.

Even if this program is not really usefull for the Nit project, it makes a concrete example on how we can use the language in the real world, so I submit it.

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

8 years agoMerge: lib: introduce MongoDB wrapper
Jean Privat [Mon, 11 May 2015 23:22:16 +0000 (19:22 -0400)]
Merge: lib: introduce MongoDB wrapper

This is my first real use of the FFI, @xymus you input on that?

Also poking @BlackMinou because he likes to review C code.

Pull-Request: #1303
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 agoBitmap class as part of the bitmap library
Budi Kurniawan [Sun, 19 Apr 2015 14:11:25 +0000 (10:11 -0400)]
Bitmap class as part of the bitmap library

Signed-off-by: Budi Kurniawan <budi2020@gmail.com>