nit.git
8 years agolib/core: Removed `last_byte` attribute in `FlatString` as it is useless
Lucas Bajolet [Tue, 8 Dec 2015 15:09:29 +0000 (10:09 -0500)]
lib/core: Removed `last_byte` attribute in `FlatString` as it is useless

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

8 years agoexpanded the nit_env.sh script to register nit within .bash_profile, .bashrc
itsWill [Fri, 25 Dec 2015 18:30:57 +0000 (19:30 +0100)]
expanded the nit_env.sh script to register nit within .bash_profile, .bashrc

Signed-off-by: itsWill <guilhermerpmansur@gmail.com>

8 years agoMerge: model: migrate model_collect to model_views
Jean Privat [Tue, 22 Dec 2015 14:13:38 +0000 (09:13 -0500)]
Merge: model: migrate model_collect to model_views

And update all the clients.

Pull-Request: #1908
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agoMerge: src: introduce Nit Static Analysis Framework
Jean Privat [Sat, 19 Dec 2015 12:27:24 +0000 (07:27 -0500)]
Merge: src: introduce Nit Static Analysis Framework

This is the first step in the introduction of a static analsysis framework for the nit language.

This PR introduces the basic behaviors of a StaticAnalysis and ForwardAnalysis.
I added ReachingDefAnalysis as an example of StaticAnalysis implementation.
I also added `nitsaf`, a client example for the saf module.

I suggest to read this PR commit by commit, I splat it in steps:
* introduce base services
* handle ifs constructs
* handle loops constructs
* handle method declaration

Next steps/PRs will be:
* introduce inter-procedural analysis
* use RTA for better inter-procedural analysis precision
* backward analysis
* add more analysis (isset checks, attr isset, unused properties, useless nullables...)

Closes #511.

Pull-Request: #1764
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agotests: skip nitsaf with niti and nitvm
Alexandre Terrasa [Sat, 19 Dec 2015 08:44:50 +0000 (03:44 -0500)]
tests: skip nitsaf with niti and nitvm

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

8 years agonitsaf: add intraprocedural analysis
Alexandre Terrasa [Sat, 19 Dec 2015 08:44:37 +0000 (03:44 -0500)]
nitsaf: add intraprocedural analysis

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

8 years agolib/collection: introduce init `HashMap::from`
Alexandre Terrasa [Sat, 24 Oct 2015 18:02:31 +0000 (14:02 -0400)]
lib/collection: introduce init `HashMap::from`

HashSet has one, why not HashMap?

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

8 years agonitsaf: add loop flow set merge
Alexandre Terrasa [Sat, 17 Oct 2015 02:40:51 +0000 (22:40 -0400)]
nitsaf: add loop flow set merge

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

8 years agonitsaf: add flow merge on `if..else` blocks
Alexandre Terrasa [Sat, 17 Oct 2015 02:40:22 +0000 (22:40 -0400)]
nitsaf: add flow merge on `if..else` blocks

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

8 years agonitsaf: add tests
Alexandre Terrasa [Fri, 16 Oct 2015 23:20:18 +0000 (19:20 -0400)]
nitsaf: add tests

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

8 years agonitsaf: introduce `nitsaf` binary
Alexandre Terrasa [Fri, 16 Oct 2015 23:10:27 +0000 (19:10 -0400)]
nitsaf: introduce `nitsaf` binary

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

8 years agonitsaf: introduce reaching defs analysis
Alexandre Terrasa [Sat, 17 Oct 2015 02:25:41 +0000 (22:25 -0400)]
nitsaf: introduce reaching defs analysis

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

8 years agonitsaf: introduce Nit Static Analysis Framework
Alexandre Terrasa [Sat, 17 Oct 2015 02:39:22 +0000 (22:39 -0400)]
nitsaf: introduce Nit Static Analysis Framework

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

8 years agonitx: migrate client to new doc API
Alexandre Terrasa [Fri, 18 Dec 2015 04:41:18 +0000 (23:41 -0500)]
nitx: migrate client to new doc API

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

8 years agonitdoc: migrate client to new doc API
Alexandre Terrasa [Wed, 16 Dec 2015 07:57:42 +0000 (02:57 -0500)]
nitdoc: migrate client to new doc API

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

8 years agonitdoc: migrate phases to model view
Alexandre Terrasa [Wed, 16 Dec 2015 07:56:57 +0000 (02:56 -0500)]
nitdoc: migrate phases to model view

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

8 years agonitdoc: make DocModel a ModelView
Alexandre Terrasa [Wed, 16 Dec 2015 07:42:11 +0000 (02:42 -0500)]
nitdoc: make DocModel a ModelView

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

8 years agodoc_base: fix warnings
Alexandre Terrasa [Wed, 16 Dec 2015 07:41:51 +0000 (02:41 -0500)]
doc_base: fix warnings

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

8 years agomodel: make Model::model behaves like for other mentities
Alexandre Terrasa [Wed, 16 Dec 2015 07:37:51 +0000 (02:37 -0500)]
model: make Model::model behaves like for other mentities

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

8 years agonitmetrics: migrate nullables metrics to model_views
Alexandre Terrasa [Wed, 16 Dec 2015 07:28:18 +0000 (02:28 -0500)]
nitmetrics: migrate nullables metrics to model_views

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

8 years agonitmetrics: migrate mendel metrics to model_views
Alexandre Terrasa [Wed, 16 Dec 2015 07:28:11 +0000 (02:28 -0500)]
nitmetrics: migrate mendel metrics to model_views

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

8 years agonitmetrics: migrate mclasses metrics to model_views
Alexandre Terrasa [Wed, 16 Dec 2015 07:28:05 +0000 (02:28 -0500)]
nitmetrics: migrate mclasses metrics to model_views

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

8 years agoautocomplete: use model views
Alexandre Terrasa [Wed, 16 Dec 2015 07:05:32 +0000 (02:05 -0500)]
autocomplete: use model views

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

8 years agonituml: use ModelView
Alexandre Terrasa [Wed, 16 Dec 2015 05:54:12 +0000 (00:54 -0500)]
nituml: use ModelView

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

8 years agonitweb: use ModelTreeVisitor instead of custom tree list
Alexandre Terrasa [Wed, 16 Dec 2015 03:07:10 +0000 (22:07 -0500)]
nitweb: use ModelTreeVisitor instead of custom tree list

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

8 years agonitweb: use MEntityTree instead of ad-hoc list
Alexandre Terrasa [Fri, 18 Dec 2015 03:03:58 +0000 (22:03 -0500)]
nitweb: use MEntityTree instead of ad-hoc list

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

8 years agonitweb: use ModelView instead of model collect
Alexandre Terrasa [Wed, 16 Dec 2015 00:35:05 +0000 (19:35 -0500)]
nitweb: use ModelView instead of model collect

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

8 years agonitweb: introduce ModelAction
Alexandre Terrasa [Wed, 16 Dec 2015 00:29:30 +0000 (19:29 -0500)]
nitweb: introduce ModelAction

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

8 years agonitweb: remove dependencies from `model_html` to `model_collect`
Alexandre Terrasa [Wed, 16 Dec 2015 00:02:46 +0000 (19:02 -0500)]
nitweb: remove dependencies from `model_html` to `model_collect`

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

8 years agomodel_collect: use model_views
Alexandre Terrasa [Wed, 16 Dec 2015 07:05:19 +0000 (02:05 -0500)]
model_collect: use model_views

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

8 years agoMerge: Faster hex parsing
Jean Privat [Fri, 18 Dec 2015 20:27:41 +0000 (15:27 -0500)]
Merge: Faster hex parsing

As said in #1895, we need faster parsing of UTF-16 escaping sequences, this PR is the answer.

It makes the runtime of the `large_escaped` benchmark go down from ~5s to ~3.5s, and with valgrind, from 26GIr to 20GIr

Note: based on #1886, only the 4 last commits are of interest here

Pull-Request: #1896
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agoMerge: core: add Text::levenshtein_distance
Jean Privat [Fri, 18 Dec 2015 20:27:37 +0000 (15:27 -0500)]
Merge: core: add Text::levenshtein_distance

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

8 years agoMerge: Better mmodule location
Jean Privat [Fri, 18 Dec 2015 20:27:32 +0000 (15:27 -0500)]
Merge: Better mmodule location

This mainly close a undocumented issue where `mmodule.location.source` is wrong

Pull-Request: #1911
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: hightlight: correctly highlight loose comments
Jean Privat [Fri, 18 Dec 2015 20:27:28 +0000 (15:27 -0500)]
Merge: hightlight: correctly highlight loose comments

close #1907

Pull-Request: #1910
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: readme: add information section
Jean Privat [Fri, 18 Dec 2015 20:27:25 +0000 (15:27 -0500)]
Merge: readme: add information section

Pull-Request: #1909
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agolib/core: Added an optimized `to_hex` function to `FlatText`
Lucas Bajolet [Fri, 18 Dec 2015 18:41:52 +0000 (13:41 -0500)]
lib/core: Added an optimized `to_hex` function to `FlatText`

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

8 years agotests: update nitx sav because more information
Jean Privat [Fri, 18 Dec 2015 16:00:02 +0000 (11:00 -0500)]
tests: update nitx sav because more information

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

8 years agonitc: use mmodule.filepath at some place
Jean Privat [Fri, 18 Dec 2015 15:59:40 +0000 (10:59 -0500)]
nitc: use mmodule.filepath at some place

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

8 years agomodel: promote MModule::filename to model::mmodule
Jean Privat [Fri, 18 Dec 2015 15:47:55 +0000 (10:47 -0500)]
model: promote MModule::filename to model::mmodule

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

8 years agoloader: update the mmodule location once the source is parsed
Jean Privat [Fri, 18 Dec 2015 15:47:22 +0000 (10:47 -0500)]
loader: update the mmodule location once the source is parsed

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

8 years agocore: add Text::levenshtein_distance
Jean Privat [Fri, 18 Dec 2015 17:44:50 +0000 (12:44 -0500)]
core: add Text::levenshtein_distance

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

8 years agohightlight: correctly highlight loose comments
Jean Privat [Fri, 18 Dec 2015 14:40:27 +0000 (09:40 -0500)]
hightlight: correctly highlight loose comments

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

8 years agoreadme: add information section
Jean Privat [Fri, 18 Dec 2015 13:57:14 +0000 (08:57 -0500)]
readme: add information section

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

8 years agoMerge: model: Beefup model visitor
Jean Privat [Fri, 18 Dec 2015 13:53:23 +0000 (08:53 -0500)]
Merge: model: Beefup model visitor

Add usefull services to model visitor and introduce a model view based on it.

Pull-Request: #1903
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agoMerge: Json benchmark
Jean Privat [Fri, 18 Dec 2015 13:53:18 +0000 (08:53 -0500)]
Merge: Json benchmark

Added a JSON parser benchmark between different languages and Nit using 3 variants:

* Nit/NitCC: The old parser relying on NitCC, which is slow and memory-consuming (more than 6 Gio RAM for the 100Mio escaping-intensive file)
* Nit/Ad-hoc UTF-8 no ropes: The new parser working exclusively on `FlatString`
* Nit/Ad-hoc UTF-8 with ropes: The new parser with a mix of `Concat` and `FlatString`

![vr5fa](https://cloud.githubusercontent.com/assets/1444825/11787549/4375a4e6-a25a-11e5-87b3-ac4346dee3bd.jpg)

I hear you all clamouring, well, here are the results (after #1885 and #1887, naturally):

![output](https://cloud.githubusercontent.com/assets/1444825/11787622/b24c0c98-a25a-11e5-8cff-0e0afe03c9d8.png)

So yeah, I guess we could do better when it comes to escaping since the biggest difference in runtime is in the `large_escape` benchmark which coincidentally contains mostly `\uXXXX` characters.

Other than that, we do as well as Go and better than Ruby (also worse than Python, but this does not count), which is nice.

About the inputs:

* large_escaped is an unusual file since it contains large strings with lots of unicode escaping sequences which should highlight the handling of String-to-Int conversions and Unicode-escape-sequences-to-UTF-8-characters, and it is big, as in very big (94.7 Mio)
* magic, a normally-formatted 54 Mio JSON file with quite a bunch of Unicode characters
* gov_data, a 6.9 Mio JSON file with ASCII characters only
* twitter, a 64 kio JSON file with a lot of japanese characters

I might add some more files later to better represent the variety of inputs, but right now is a good time to push the benchmark suite, enjoy !

Note: Since the ad-hoc JSON parser is benched, #1886 will need to be merged prior to this one if the bench is to work on your machines

Pull-Request: #1895
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agotests: update tests for model_visitor
Alexandre Terrasa [Fri, 18 Dec 2015 05:13:10 +0000 (00:13 -0500)]
tests: update tests for model_visitor

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

8 years agomodel_view: introduce views to model based on model visitor
Alexandre Terrasa [Tue, 15 Dec 2015 23:22:55 +0000 (18:22 -0500)]
model_view: introduce views to model based on model visitor

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

8 years agomodel: introduce MEntityTree
Alexandre Terrasa [Fri, 18 Dec 2015 03:03:37 +0000 (22:03 -0500)]
model: introduce MEntityTree

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

8 years agomodel: beef up ModelVisitor
Alexandre Terrasa [Wed, 16 Dec 2015 02:09:20 +0000 (21:09 -0500)]
model: beef up ModelVisitor

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

8 years agocontrib/pep8analysis: Fix operand check in hexdigit
Lucas Bajolet [Tue, 15 Dec 2015 16:51:28 +0000 (11:51 -0500)]
contrib/pep8analysis: Fix operand check in hexdigit

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

8 years agolib/json: Improved performance of Unicode-escaping in a `Text`
Lucas Bajolet [Tue, 15 Dec 2015 16:26:30 +0000 (11:26 -0500)]
lib/json: Improved performance of Unicode-escaping in a `Text`

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

8 years agolib: Perfized `to_hex` and have it work anywhere in a `Text`
Lucas Bajolet [Mon, 14 Dec 2015 22:31:53 +0000 (17:31 -0500)]
lib: Perfized `to_hex` and have it work anywhere in a `Text`

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

8 years agolib: Added `is_surrogate` service to `Char`
Lucas Bajolet [Mon, 14 Dec 2015 22:31:16 +0000 (17:31 -0500)]
lib: Added `is_surrogate` service to `Char`

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

8 years agolib: Added `from_hex` service to transform an hexadecimal digit to an `Int`
Lucas Bajolet [Mon, 14 Dec 2015 22:30:58 +0000 (17:30 -0500)]
lib: Added `from_hex` service to transform an hexadecimal digit to an `Int`

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

8 years agotests: rm sav/niti/fixme/test_intern_extern.res from #1898 because #1902 fixed it
Jean Privat [Thu, 17 Dec 2015 16:05:57 +0000 (11:05 -0500)]
tests: rm sav/niti/fixme/test_intern_extern.res from #1898 because #1902 fixed it

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

8 years agoMerge: FFI: Fix extern methods in generic classes with the interpreter, and complex...
Jean Privat [Thu, 17 Dec 2015 16:03:02 +0000 (11:03 -0500)]
Merge: FFI: Fix extern methods in generic classes with the interpreter, and complex types with nith

A kind of resolve was missing so the name of the generated C function was different between the call and its implementation.

Fix #1899.

Pull-Request: #1902
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agoMerge: Alternative intern
Jean Privat [Thu, 17 Dec 2015 16:02:55 +0000 (11:02 -0500)]
Merge: Alternative intern

Improve the handling of alternative of intern methods since an extern body can be used as a fallback.

~~~
redef class Int
   fun foo is intern `{ return foo(self) `}
end
~~~

Moreover, NativeArray intern alternatives is now fixed with nitc.

There is still an issue with the extern methods of NativeArray in the interpreter.

Pull-Request: #1898
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: Asteronits: add sounds and decouple app::audio from mnit
Jean Privat [Thu, 17 Dec 2015 16:02:44 +0000 (11:02 -0500)]
Merge: Asteronits: add sounds and decouple app::audio from mnit

Add some sound effects to Asteronits, when opening fire, on asteroid explosion and on collisions with the ship. There is no sound for the thruster because the pause feature is currently broken on Android and inexistant on GNU/Linux.

Also update app::soounds so they no longer depend on mnit and now rely only on app.nit.

Pull-Request: #1901
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agobenchmarks: Added Makefile for bench_json
Lucas Bajolet [Mon, 14 Dec 2015 16:53:34 +0000 (11:53 -0500)]
benchmarks: Added Makefile for bench_json

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

8 years agobenchmarks: Added multiplier for small JSON files
Lucas Bajolet [Wed, 16 Dec 2015 16:50:53 +0000 (11:50 -0500)]
benchmarks: Added multiplier for small JSON files

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

8 years agoFFI nith: fix using `void*` for generics and nullables types in the light FFI
Alexis Laferrière [Thu, 17 Dec 2015 15:11:55 +0000 (10:11 -0500)]
FFI nith: fix using `void*` for generics and nullables types in the light FFI

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

8 years agoFFI niti: fix extern methods in generic classes
Alexis Laferrière [Thu, 17 Dec 2015 14:50:24 +0000 (09:50 -0500)]
FFI niti: fix extern methods in generic classes

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

8 years agotests: add a test for extern methods in generic classes
Alexis Laferrière [Thu, 17 Dec 2015 14:49:32 +0000 (09:49 -0500)]
tests: add a test for extern methods in generic classes

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

8 years agonitni: can mangle all formal type, not just virtual ones
Jean Privat [Tue, 15 Dec 2015 22:22:34 +0000 (17:22 -0500)]
nitni: can mangle all formal type, not just virtual ones

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

8 years agoMerge: nitrpg: avoid race conditions in tests that imply database
Jean Privat [Wed, 16 Dec 2015 20:07:39 +0000 (15:07 -0500)]
Merge: nitrpg: avoid race conditions in tests that imply database

As asked by @privat, the nitrpg test suite now uses random db names

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

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

8 years agoMerge: Qualified class identifiers
Jean Privat [Wed, 16 Dec 2015 17:12:30 +0000 (12:12 -0500)]
Merge: Qualified class identifiers

Extends the parsed and the AST to handle qualified class identifiers.

Now you can parse

~~~nit
redef class m0::A
        super m1::S
        redef type m2::B::T: Int
        fun foo: m3::G[m4::C] do end
end
~~~

Currently, the class qualifiers, if any, are just ignored by semantic phases. Like with method qualifiers.

Pull-Request: #1900
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agoMerge: niunit: fix after/before test calls
Jean Privat [Wed, 16 Dec 2015 17:12:22 +0000 (12:12 -0500)]
Merge: niunit: fix after/before test calls

The specification of `nitunit` states that before and after methods can be called to initialize or clean test related things:

~~~nit
module my_test_suite

class MyTestSuite
    super TestSuite

    redef fun before_test do
          # complex things to set up the test
    end

    redef fun after_test do
          # complex things to tear down the test
    end

    fun test_foo do end
    fun test_bar do end
end
~~~

In the above example, `nitunit` will call the methods precisely in this order:

~~~nit
test_before
test_foo
test_after
test_before
test_bar
test_after
~~~

Before this PR, the before and after methods were only call if a redefinition of the before/after method exists locally in the test suite. Inheritance was not considered:

~~~nit
module my_test_suite

class TestBase
    super TestSuite

    redef fun before_test do # ...
    redef fun after_test do # ...
end

class MyTestSuite
    super TestBase

    fun test_foo do end
    fun test_bar do end
end
~~~

So the output was only:

~~~nit
test_foo
test_bar
~~~

This PR fixes that behavior.

Pull-Request: #1897
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agoMerge: gamnit: simple 2D API, input events and the game Asteronits
Jean Privat [Wed, 16 Dec 2015 17:12:20 +0000 (12:12 -0500)]
Merge: gamnit: simple 2D API, input events and the game Asteronits

You should probably read this PR commit by commit, it is a bit long but it's mostly due to the sample game, a big XML file and changes to indentation.

The new API provided by `simple_2d` is meant to replace mnit for writing 2D games.
Client modules only have to create instances of `Sprite` which will be displayed as long as they are in `App::sprites`.

At this point, the `simple_2d` API is not optimized and you may see a slowdown at the insertion of new sprites. However, we could improve the performance by preallocating buffer space for more sprites, and by caching sprites state on the GPU to avoid unnecessary updates.

This PR also adds support for input events for Linux and Android. It uses the existing services from `mnit::input`, `sdl` and `android::input_events`.

Finally, the game Asteronits is an example for the `simple_2d` API. In this game, the player controls a ship, avoids asteroids and destroys them. The gameplay and UI is limited by design to be a simple example. Note that the `touch_ui` variant is used on Android only but it also works on Linux.

The tool texture_atlas_parser reads XML TextureAtlas files and produces Nit classes with one attribute per subtexture. We could move this tool if it is useful for any other projects.

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

8 years agoMerge: Json Ad-Hoc string parser
Jean Privat [Wed, 16 Dec 2015 17:12:13 +0000 (12:12 -0500)]
Merge: Json Ad-Hoc string parser

Simple ad-hoc JSON parser working in a similar way as `DOMXmlParser` or `SExpParser`, on the simple  example, the runtime now is around 1.5 seconds.

Once #1885 is merged however, the runtime is ~0.65 seconds, which is nice.

Depends on #1884

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

8 years agobenchmarks: Added JSON benchmark script
Lucas Bajolet [Thu, 10 Dec 2015 20:47:48 +0000 (15:47 -0500)]
benchmarks: Added JSON benchmark script

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

8 years agotests: Update sav without escaped `/` characters in a string
Lucas Bajolet [Sun, 13 Dec 2015 18:57:07 +0000 (13:57 -0500)]
tests: Update sav without escaped `/` characters in a string

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

8 years agotests: Added ad-hoc json parser test
Lucas Bajolet [Tue, 8 Dec 2015 19:20:23 +0000 (14:20 -0500)]
tests: Added ad-hoc json parser test

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

8 years agolib/json: Added ad-hoc string parser for JSON
Lucas Bajolet [Fri, 11 Dec 2015 21:35:53 +0000 (16:35 -0500)]
lib/json: Added ad-hoc string parser for JSON

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

8 years agolib/android: fix frenglish doc
Alexis Laferrière [Tue, 15 Dec 2015 22:35:18 +0000 (17:35 -0500)]
lib/android: fix frenglish doc

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

8 years agocontrib/asteronits: intro Android version with vibration
Alexis Laferrière [Tue, 15 Dec 2015 22:34:47 +0000 (17:34 -0500)]
contrib/asteronits: intro Android version with vibration

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

8 years agocontrib/asteronits: add sound effects
Alexis Laferrière [Tue, 15 Dec 2015 16:41:51 +0000 (11:41 -0500)]
contrib/asteronits: add sound effects

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

8 years agolib/linux: audio has no more needs for mnit
Alexis Laferrière [Tue, 15 Dec 2015 15:35:46 +0000 (10:35 -0500)]
lib/linux: audio has no more needs for mnit

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

8 years agolib: move assets_dir
Alexis Laferrière [Wed, 7 Oct 2015 15:38:34 +0000 (11:38 -0400)]
lib: move assets_dir

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

8 years agocontrib/asteronits: fix android rules dependency on pre-build
Alexis Laferrière [Wed, 16 Dec 2015 13:21:14 +0000 (08:21 -0500)]
contrib/asteronits: fix android rules dependency on pre-build

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

8 years agotests: update sav for AST-related tests
Jean Privat [Wed, 16 Dec 2015 05:16:38 +0000 (00:16 -0500)]
tests: update sav for AST-related tests

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

8 years agonitc: update code to use qclassids
Jean Privat [Wed, 16 Dec 2015 04:23:10 +0000 (23:23 -0500)]
nitc: update code to use qclassids

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

8 years agoparser: regenerate (with qclassid)
Jean Privat [Wed, 16 Dec 2015 04:22:37 +0000 (23:22 -0500)]
parser: regenerate (with qclassid)

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

8 years agoparser: use qualified class ids in the AST (changes API)
Jean Privat [Wed, 16 Dec 2015 04:22:07 +0000 (23:22 -0500)]
parser: use qualified class ids in the AST (changes API)

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

8 years agoparser: expose qualified class id (qclassid)
Jean Privat [Wed, 16 Dec 2015 04:21:17 +0000 (23:21 -0500)]
parser: expose qualified class id (qclassid)

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

8 years agomodel: fix some warnings
Alexandre Terrasa [Wed, 16 Dec 2015 01:33:21 +0000 (20:33 -0500)]
model: fix some warnings

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

8 years agocontrib/asteronits: fix dependency on inkscape_tools
Alexis Laferrière [Tue, 15 Dec 2015 23:18:04 +0000 (18:18 -0500)]
contrib/asteronits: fix dependency on inkscape_tools

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

8 years agonitrpg: avoid race conditions in tests that imply database
Alexandre Terrasa [Tue, 15 Dec 2015 01:58:49 +0000 (20:58 -0500)]
nitrpg: avoid race conditions in tests that imply database

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

8 years agotest: add test_intern_extern.nit
Jean Privat [Tue, 15 Dec 2015 22:28:32 +0000 (17:28 -0500)]
test: add test_intern_extern.nit

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

8 years agointerpreter: a method can be extern and intern, extern is used as a fallback
Jean Privat [Tue, 15 Dec 2015 22:24:25 +0000 (17:24 -0500)]
interpreter: a method can be extern and intern, extern is used as a fallback

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

8 years agonitni: can mangle all formal type, not just virtual ones
Jean Privat [Tue, 15 Dec 2015 22:22:34 +0000 (17:22 -0500)]
nitni: can mangle all formal type, not just virtual ones

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

8 years agocompiler: a method can be extern and intern, extern is used as a fallback
Jean Privat [Tue, 15 Dec 2015 22:07:06 +0000 (17:07 -0500)]
compiler: a method can be extern and intern, extern is used as a fallback

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

8 years agonitunit: always call before/after methods
Alexandre Terrasa [Tue, 15 Dec 2015 22:04:23 +0000 (17:04 -0500)]
nitunit: always call before/after methods

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

8 years agonitunit: add a test to show how non-local redefinition of before/after methods should...
Alexandre Terrasa [Tue, 15 Dec 2015 22:04:02 +0000 (17:04 -0500)]
nitunit: add a test to show how non-local redefinition of before/after methods should work

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

8 years agocompiler: intern methods on NativeArray can fallback instead of no-op
Jean Privat [Tue, 15 Dec 2015 21:59:38 +0000 (16:59 -0500)]
compiler: intern methods on NativeArray can fallback instead of no-op

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

8 years agonitunit: clean warnings for testing_suite
Alexandre Terrasa [Tue, 15 Dec 2015 21:56:43 +0000 (16:56 -0500)]
nitunit: clean warnings for testing_suite

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

8 years agoMerge: nitweb: nitcorn based API to access model and source code
Jean Privat [Tue, 15 Dec 2015 19:19:47 +0000 (14:19 -0500)]
Merge: nitweb: nitcorn based API to access model and source code

Description from man page:

# NAME

nitweb - provide a web API to nit model and source code.

# SYNOPSIS

nitweb [*options*] FILE...

# DESCRIPTION

`nitweb` use `nitcorn` actions to provide an API to loaded model and source code.

Usage:

~~~sh
nitweb --host localhost --port 3000 lib/core/
~~~

### `GET /` HOME
Show the home page of the webserver.
Display all the loaded model entities in a tree.

### `GET /search/:namespace` SEARCH BY NAMESPACE
Search all model entities matching `namespace`.

It is possible to retrieve the result as a JsonArray instead of raw html
using the uri param `json=true` (default `false`).

### `GET /code/:namespace` SHOW SOURCE CODE
Display the source code of the entity matching `namespace`.

### `GET /doc/:namespace` DOCUMENTATION PAGE
Display a short documentation page about the entity matching `namespace`.

### `GET /random/` RANDOM LIST
Display a random list of entities found in the model.

The list is parametrable with the following uri params:
* `n=10` size of the list (default `10`)
* `k=modules` kind of entities in the list (default `modules`)

It is possible to retrieve the result as a JsonArray instead of raw html
using the uri param `json=true` (default `false`).

# OPTIONS

### `--host`
The host to bind the web server on.

### `--port`
Port number to use

### `-h`, `-?`, `--help`
Show Help (the list of options).

Pull-Request: #1889
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agoMerge: Add simple proxy action
Jean Privat [Tue, 15 Dec 2015 18:42:10 +0000 (13:42 -0500)]
Merge: Add simple proxy action

For now anything proxied using this action is blocking.

close #1845

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

8 years agobenchmarks: Added benchmarks for C, Go, Ruby, Python and Nit
Lucas Bajolet [Thu, 10 Dec 2015 20:47:27 +0000 (15:47 -0500)]
benchmarks: Added benchmarks for C, Go, Ruby, Python and Nit

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

8 years agoMerge: Make all Sets cloneable
Jean Privat [Tue, 15 Dec 2015 14:31:27 +0000 (09:31 -0500)]
Merge: Make all Sets cloneable

Since there is no reason to forbid it (or I have not seen one at the very least), here's a simple `clone` method that should work on any `Set`

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

8 years agocontrib/asteronits: fix check rule
Alexis Laferrière [Tue, 15 Dec 2015 13:09:12 +0000 (08:09 -0500)]
contrib/asteronits: fix check rule

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