nit.git
8 years agotests: Updated `test_substring` for edge case in `ASCIIFlatString::substring`
Lucas Bajolet [Mon, 16 May 2016 20:01:36 +0000 (16:01 -0400)]
tests: Updated `test_substring` for edge case in `ASCIIFlatString::substring`

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

8 years agolib/core: Fix substring in `ASCIIFlatString`
Lucas Bajolet [Mon, 16 May 2016 19:59:03 +0000 (15:59 -0400)]
lib/core: Fix substring in `ASCIIFlatString`

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

8 years agoMerge: Some nitunit love
Jean Privat [Sat, 14 May 2016 15:56:13 +0000 (11:56 -0400)]
Merge: Some nitunit love

Two small changes

* nitunit works on directories. e.g. `nitunit lib/ contrib/`
* static errors are shown with precise location.

~~~
test_doc3.nit:17,9--15: Syntax Error: unexpected identifier 'garbage'. To suppress this message, enclose the block with a fence tagged `nitish` or `raw` (see `man nitdoc`). (invalid-block)
#      *garbage*
        ^
~~~

runtime errors are a more complex beast to track. Two solutions:

* pragma to inject line informations in the generated test program. This need to find a syntax for line pragmas and teach the parser to use them
* post-error management that parse error messages and substitute the locations from the the generated program with the original locations in the real source. Doable but more code is needed.

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

8 years agoMerge: CSV Benchmarks
Jean Privat [Sat, 14 May 2016 15:56:12 +0000 (11:56 -0400)]
Merge: CSV Benchmarks

This PR introduces a new benchmark script for CSV parsers.

Are tested here:

* Nit CSV Ad-hoc parser
* Go standard parser
* Java Apache Commons CSV parser
* Python - Pandas
* Python - Standard
* Ruby - Standard

Will upload some measurements later but *spoiler alert* Python - Pandas is the fastest on large files, Ruby is the slowest by far, Java is the second slower with a big margin from the rest.
Go/Nit/Python-Standard are almost equivalent.

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

8 years agoMerge: Add a Dockerfile to build a full image of a Nit install
Jean Privat [Sat, 14 May 2016 15:56:10 +0000 (11:56 -0400)]
Merge: Add a Dockerfile to build a full image of a Nit install

The image is based on Debian stable (jessie) with a lot of packages.
I'm not sure what is the point of such images for the end-users.

My objective was just to test a Nit installation on a fresh, full & reproductible base.

Image will be available in the docker hub: https://hub.docker.com/r/nitlang/nit/

The only tests that fails are:

* ballz_android dino_android shoot_android ui_test test_platform_android: no android
* emscripten_nodejs: no emstripten
* test_neo_args1 test_neo4j test_neo4j_batch: no neo4j
* mpi_simple: bizarre error messages
* simple_file_server: the user is root so 80 can be opened :/
* test_glsl_validation: not installed

nitunit need also to be run

Pull-Request: #2070
Reviewed-by: Jean-Philippe Caissy <jpcaissy@piji.ca>

8 years agoMerge: Rubix cube - Catalog and documentation update
Jean Privat [Sat, 14 May 2016 02:19:43 +0000 (22:19 -0400)]
Merge: Rubix cube - Catalog and documentation update

A .ini file has been added for support in catalog, along with some module documentation for `lib/rubix.nit`

Close #2076.

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

8 years agoMerge: Promote location in MEntity
Jean Privat [Sat, 14 May 2016 02:19:34 +0000 (22:19 -0400)]
Merge: Promote location in MEntity

For some unknown historical reasons, the location was only provided to some specific model entities. By extending it to all entities, this simplify clients that need to process, visit or filter entities.

Location is not nullable for all entities. This is simpler but need some place-holder object for fictive location. ie some location objects that mean "no location".

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

8 years agonitc/neo.nit: adapt code to promoted locations
Jean Privat [Fri, 13 May 2016 20:48:46 +0000 (16:48 -0400)]
nitc/neo.nit: adapt code to promoted locations

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

8 years agonitc/model: add location to MType
Jean Privat [Sun, 1 May 2016 18:55:03 +0000 (14:55 -0400)]
nitc/model: add location to MType

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

8 years agonitc: model_visitor shows the location
Jean Privat [Sun, 1 May 2016 15:58:50 +0000 (11:58 -0400)]
nitc: model_visitor shows the location

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

8 years agomodel: add location to MClass and MProperty
Jean Privat [Sun, 1 May 2016 15:45:51 +0000 (11:45 -0400)]
model: add location to MClass and MProperty

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

8 years agomodel: filepath is now just an alias on the location
Jean Privat [Fri, 13 May 2016 17:53:50 +0000 (13:53 -0400)]
model: filepath is now just an alias on the location

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

8 years agomodel: add location to packages and groups
Jean Privat [Sun, 1 May 2016 15:43:36 +0000 (11:43 -0400)]
model: add location to packages and groups

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

8 years agomodel: promote location to any `MEntity`
Jean Privat [Sun, 1 May 2016 15:42:20 +0000 (11:42 -0400)]
model: promote location to any `MEntity`

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

8 years agolib: Added catalog ini for `rubix` project
Lucas Bajolet [Fri, 13 May 2016 19:28:06 +0000 (15:28 -0400)]
lib: Added catalog ini for `rubix` project

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

8 years agolib: Added documentation on rubix module
Lucas Bajolet [Fri, 13 May 2016 19:27:33 +0000 (15:27 -0400)]
lib: Added documentation on rubix module

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

8 years agobenchmarks/csv: Added README
Lucas Bajolet [Thu, 12 May 2016 19:22:33 +0000 (15:22 -0400)]
benchmarks/csv: Added README

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

8 years agobenchmarks: Added CSV benchmark to bench suite
Lucas Bajolet [Thu, 12 May 2016 19:22:20 +0000 (15:22 -0400)]
benchmarks: Added CSV benchmark to bench suite

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

8 years agonitc/location: add named constructor `opaque_file`
Jean Privat [Sun, 1 May 2016 15:39:28 +0000 (11:39 -0400)]
nitc/location: add named constructor `opaque_file`

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

8 years agoMerge: lib/base64: Support line breaks in base64 strings.
Jean Privat [Fri, 13 May 2016 17:18:42 +0000 (13:18 -0400)]
Merge: lib/base64: Support line breaks in base64 strings.

This allows to read directly ascii-armored blocks.

close #2069

Pull-Request: #2071
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 agoMerge: Introduce crapto modules for cryptographic attacks.
Jean Privat [Fri, 13 May 2016 17:18:37 +0000 (13:18 -0400)]
Merge: Introduce crapto modules for cryptographic attacks.

Introduce a frequency analysis service for the english language.

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

8 years agotests: unitunit gives more precise error locations
Jean Privat [Fri, 13 May 2016 17:14:58 +0000 (13:14 -0400)]
tests: unitunit gives more precise error locations

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

8 years agonitunit: give precise error location on invalid docunits.
Jean Privat [Fri, 13 May 2016 14:21:58 +0000 (10:21 -0400)]
nitunit: give precise error location on invalid docunits.

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

8 years agoIntroduce lib/crapto and a frequency analysis service.
Philippe Pepos Petitclerc [Tue, 10 May 2016 19:29:31 +0000 (15:29 -0400)]
Introduce lib/crapto and a frequency analysis service.

Signed-off-by: Philippe Pepos Petitclerc <ppeposp@gmail.com>

8 years agonitc/loader: filter_nit_source accept directories
Jean Privat [Fri, 13 May 2016 01:14:06 +0000 (21:14 -0400)]
nitc/loader: filter_nit_source accept directories

so `nitunit lib/` will test all the package of the `lib/` directory

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

8 years agolib/base64: Support line breaks in base64 strings.
Philippe Pepos Petitclerc [Thu, 12 May 2016 19:06:31 +0000 (15:06 -0400)]
lib/base64: Support line breaks in base64 strings.

This allows to read directly ascii-armored blocks.

Signed-off-by: Philippe Pepos Petitclerc <ppeposp@gmail.com>

8 years agoAdd a Dockerfile to build a full image of a Nit install
Jean Privat [Thu, 12 May 2016 18:19:00 +0000 (14:19 -0400)]
Add a Dockerfile to build a full image of a Nit install

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

8 years agoMerge: Calculator: add scientific features and nicer adaptations for Android and iOS
Jean Privat [Wed, 11 May 2016 23:11:47 +0000 (19:11 -0400)]
Merge: Calculator: add scientific features and nicer adaptations for Android and iOS

This is a long overdue update to the calculator which is the reference example for the _app.nit_ framework.

This PR adds scientific operations and constants to the calculator, directly in the logic, and only as a refinement of the UI. There is also new aesthetic adaptations for Android and iOS.

The calculator now uses Unicode operators like ÷ and ×, and internally a string instead of a `FlatBuffer` for simplicity. This change revealed errors in FFI wrappers where `to_s_with_copy` should have been used.

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

8 years agoMerge: Added a service to xor `Bytes`
Jean Privat [Wed, 11 May 2016 23:11:44 +0000 (19:11 -0400)]
Merge: Added a service to xor `Bytes`

Needed a new constructor for `Bytes` to facilitate things.

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

8 years agoMerge: Update gitignore to exclude DS_Store
Jean Privat [Wed, 11 May 2016 23:11:41 +0000 (19:11 -0400)]
Merge: Update gitignore to exclude DS_Store

The .DS_Store file is automatically generated by the Mac OS filesystem to keep metainformation about that directory. This files is unnecessary to the project so should be excluded in the .gitignore

@privat

Pull-Request: #2060
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 agolib/crypto: Remove xor cipher on Text.
Philippe Pepos Petitclerc [Wed, 11 May 2016 20:37:57 +0000 (16:37 -0400)]
lib/crypto: Remove xor cipher on Text.

It could be counter intuitive because of unicode. Explicitly casting to `Bytes`
first will be clearer.

Signed-off-by: Philippe Pepos Petitclerc <ppeposp@gmail.com>

8 years agolib/crypto: Add a xor'ing function to Bytes.
Philippe Pepos Petitclerc [Tue, 10 May 2016 18:44:52 +0000 (14:44 -0400)]
lib/crypto: Add a xor'ing function to Bytes.

Signed-off-by: Philippe Pepos Petitclerc <ppeposp@gmail.com>

8 years agocalculator: implement unary minus
Alexis Laferrière [Wed, 11 May 2016 18:13:34 +0000 (14:13 -0400)]
calculator: implement unary minus

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

8 years agocalculator: add screenshots to the README
Alexis Laferrière [Wed, 11 May 2016 17:09:43 +0000 (13:09 -0400)]
calculator: add screenshots to the README

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

8 years agocalculator: mobile apps use the scientific variant
Alexis Laferrière [Thu, 5 May 2016 19:09:17 +0000 (15:09 -0400)]
calculator: mobile apps use the scientific variant

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

8 years agocalculator: intro iOS adaptation
Alexis Laferrière [Wed, 11 May 2016 17:31:35 +0000 (13:31 -0400)]
calculator: intro iOS adaptation

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

8 years agocalculator: intro Android adaptation
Alexis Laferrière [Sun, 1 May 2016 21:43:48 +0000 (17:43 -0400)]
calculator: intro Android adaptation

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

8 years agocalculator: add scientific variation to the portable app
Alexis Laferrière [Wed, 11 May 2016 16:00:34 +0000 (12:00 -0400)]
calculator: add scientific variation to the portable app

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

8 years agocalculator: extend the calculator logic with scientific operators
Alexis Laferrière [Sun, 1 May 2016 19:11:14 +0000 (15:11 -0400)]
calculator: extend the calculator logic with scientific operators

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

8 years agocalculator: replace the FlatBuffer with a simple String
Alexis Laferrière [Thu, 5 May 2016 21:50:38 +0000 (17:50 -0400)]
calculator: replace the FlatBuffer with a simple String

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

8 years agocalculator: use Unicode strings instead of single chars for operators
Alexis Laferrière [Sun, 1 May 2016 19:10:44 +0000 (15:10 -0400)]
calculator: use Unicode strings instead of single chars for operators

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

8 years agolib/cocoa: fix NSString::to_s to use to_s_with_copy
Alexis Laferrière [Wed, 11 May 2016 17:57:53 +0000 (13:57 -0400)]
lib/cocoa: fix NSString::to_s to use to_s_with_copy

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

8 years agolib/gtk: copy all strings into Nit memory
Alexis Laferrière [Thu, 5 May 2016 20:03:12 +0000 (16:03 -0400)]
lib/gtk: copy all strings into Nit memory

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

8 years agoupdated .gitignore to ignore .DS_Store
itsWill [Tue, 10 May 2016 20:06:12 +0000 (22:06 +0200)]
updated .gitignore to ignore .DS_Store

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

8 years agoMerge: JSON Parser Optimization
Jean Privat [Tue, 10 May 2016 14:32:32 +0000 (10:32 -0400)]
Merge: JSON Parser Optimization

This PR improves the speed of JSON parsing with the `string_parser` module. The new version of `parse_json_string` is heavily inspired by Python's implementation, available [here](https://github.com/python/cpython/blob/master/Modules/_json.c)

Time is usually either as performing as before or better, Valgrind also gives the new version an advantage, sometimes significant.

On `large_escaped` (~120M, lots of escaped characters), we have:

* Before: 13 748 436 458 Ir
* After: 11 687 104 643 Ir

i.e. an improvement of ~18%

Time is:
* Before: 0m4.428s
* After: 0m3.932s

i.e. an improvement of ~13%

Note that on this particular test, although the number of allocations is limited as much as we can, Boehm still cannibalizes the runtime, seeing that the real time is ~2.6s.
Perf gives a total time of ~38% in GC_mark and ~7% in GC_cache_miss.

Some more optimizations can be thought, but this shows how important a good GC is necessary for the future, this program can be a good metric of how GC usage can be improved.

For further reference, Python3 on the same test gives the following output on time and Valgrind:

* Time (user): 0m1.760s
* Time (real): 0m2.177s
* Valgrind: 8 845 966 867 Ir

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

8 years agoMerge: bugfix: `is optional` attributes was evaluated too much
Jean Privat [Tue, 10 May 2016 14:31:50 +0000 (10:31 -0400)]
Merge: bugfix: `is optional` attributes was evaluated too much

`is optional` attribute must not be evaluated on the allocation, but only if `null` is given in the `new`.

Since the use of `is optional` did not spread, no one seems to have been bitten yet.

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

8 years agolib/core: Perfize reset in `FlatBuffer`
Lucas Bajolet [Mon, 9 May 2016 19:11:27 +0000 (15:11 -0400)]
lib/core: Perfize reset in `FlatBuffer`

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

8 years agolib/core: Replaced FFI version of set_char_at by pure Nit
Lucas Bajolet [Fri, 6 May 2016 20:33:07 +0000 (16:33 -0400)]
lib/core: Replaced FFI version of set_char_at by pure Nit

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

8 years agolib/core: Added new `append_substring` service to avoid creating ephemeral instances
Lucas Bajolet [Fri, 6 May 2016 20:32:45 +0000 (16:32 -0400)]
lib/core: Added new `append_substring` service to avoid creating ephemeral instances

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

8 years agolib/json: Faster `parse_json_string` implementation
Lucas Bajolet [Fri, 6 May 2016 20:32:04 +0000 (16:32 -0400)]
lib/json: Faster `parse_json_string` implementation

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

8 years agoMerge: Flatbuffer fix
Jean Privat [Fri, 6 May 2016 20:31:25 +0000 (16:31 -0400)]
Merge: Flatbuffer fix

Fix a bug at initialization of a flat buffer from a string.

Reported by @BlackMinou

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

8 years agoMerge: lib/fixed_ints: fix crash on `"-".is_int`
Jean Privat [Fri, 6 May 2016 20:31:22 +0000 (16:31 -0400)]
Merge: lib/fixed_ints: fix crash on `"-".is_int`

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

8 years agotests: Added test for `FlatBuffer::from`
Lucas Bajolet [Fri, 6 May 2016 17:38:41 +0000 (13:38 -0400)]
tests: Added test for `FlatBuffer::from`

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

8 years agolib/json: Implemented `pretty_json_visit` on JsonParseError
Lucas Bajolet [Fri, 6 May 2016 15:43:09 +0000 (11:43 -0400)]
lib/json: Implemented `pretty_json_visit` on JsonParseError

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

8 years agolib/core: Added surrogate detection methods to `Char`
Lucas Bajolet [Fri, 6 May 2016 15:42:39 +0000 (11:42 -0400)]
lib/core: Added surrogate detection methods to `Char`

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

8 years agolib/core: Fix `new FlatBuffer.from`
Lucas Bajolet [Thu, 5 May 2016 15:05:42 +0000 (11:05 -0400)]
lib/core: Fix `new FlatBuffer.from`

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

8 years agotests: update result of test_text_stat for change to is_int
Alexis Laferrière [Thu, 5 May 2016 17:26:16 +0000 (13:26 -0400)]
tests: update result of test_text_stat for change to is_int

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

8 years agolib/fixed_ints: fix crash on `"-".is_int`
Alexis Laferrière [Sun, 1 May 2016 21:33:53 +0000 (17:33 -0400)]
lib/fixed_ints: fix crash on `"-".is_int`

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

8 years agoMerge: Fix RopeBytes
Jean Privat [Thu, 5 May 2016 01:30:28 +0000 (21:30 -0400)]
Merge: Fix RopeBytes

A bug had found its way into RopeBytes when merging UTF-8, this PR should fix the issues with it.

Close #2014

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

8 years agoMerge: Examples class name
Jean Privat [Thu, 5 May 2016 01:30:17 +0000 (21:30 -0400)]
Merge: Examples class name

@Morriar was interested in the `try_get_mclass_by_id` for its documentation services but wanted to pass a string (and not a AST node) and work on all module (not just one).

I suggested to use parse_something to transform the string into a qualified class name then filter the classes of the model on it. As an experimentation, I wrote a simple example program that does this.

@Morriar then suggested to put the sample program in the repository to document how can the various tools of the model can be used to do things.

This PR inaugurate the new directory `src/examples` that is intended to contains small snippets and programs that use the `nitc` package.

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

8 years agoMerge: Clean some errors in benches
Jean Privat [Thu, 5 May 2016 01:30:15 +0000 (21:30 -0400)]
Merge: Clean some errors in benches

add html output for json and fix two issues in http://gresil.org/jenkins/job/nit_bench/120/testReport/

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

8 years agotests: add base_is_optional to check the evaluation order of attribute values
Jean Privat [Wed, 4 May 2016 14:27:17 +0000 (10:27 -0400)]
tests: add base_is_optional to check the evaluation order of attribute values

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

8 years agonitc/engines: do not initialize optional attributes on the allocation
Jean Privat [Wed, 4 May 2016 14:25:50 +0000 (10:25 -0400)]
nitc/engines: do not initialize optional attributes on the allocation

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

8 years agolib/core: Fix RopeBytes::[]
Lucas Bajolet [Tue, 3 May 2016 19:53:06 +0000 (15:53 -0400)]
lib/core: Fix RopeBytes::[]

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

8 years agotests: tests also programs from `src/examples/`
Jean Privat [Tue, 3 May 2016 15:45:48 +0000 (11:45 -0400)]
tests: tests also programs from `src/examples/`

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

8 years agotests: update error message for class name hints
Jean Privat [Tue, 3 May 2016 19:50:25 +0000 (15:50 -0400)]
tests: update error message for class name hints

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

8 years agonitc/examples: inaugurate the directory with `get_mclasses`
Jean Privat [Tue, 3 May 2016 15:44:54 +0000 (11:44 -0400)]
nitc/examples: inaugurate the directory with `get_mclasses`

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

8 years agomodelbuilder: improve hint engine with two levenshtein
Jean Privat [Tue, 3 May 2016 19:49:59 +0000 (15:49 -0400)]
modelbuilder: improve hint engine with two levenshtein

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

8 years agolib/more_collections: add `BestDistance` as an helper class
Jean Privat [Tue, 3 May 2016 15:14:57 +0000 (11:14 -0400)]
lib/more_collections: add `BestDistance` as an helper class

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

8 years agoMerge: Simplify CSV
Jean Privat [Tue, 3 May 2016 15:04:31 +0000 (11:04 -0400)]
Merge: Simplify CSV

This PR is a rewriting of the CSV library, it should now be easier to use and should not fail anymore due to `\r\n` being the default, this one has been replaced by a single `\n` character.

The `CSVFormat` class has been removed since it introduced more complexity than usefulness, and now the separator, eol and delimiter can be set independently after creation of the `CsvDocument` or a `CsvReader/Writer`.

Concerning performance, the new parser is way faster than the old one.
On a simple 4Mio file, parsing used to take 2.401s.
On the new parser, the measured user time is 0.179s, hence an improvement by a factor of ~12.

Old code sample
~~~nit
import csv

var fl = new FileReader.open(args[0])
var rd = new CsvReader.with_format(fl, new CsvFormat('"', ',', "\r"))

var lns = new Array[Array[String]]
for i in rd do lns.add i
~~~

New code sample
~~~nit
import csv

var rd = new CsvReader.from_string(args[0].to_path.read_all)
rd.eol = "\r"
rd.read_all
~~~

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

8 years agoMerge: Perfize FlatBuffer
Jean Privat [Tue, 3 May 2016 15:03:29 +0000 (11:03 -0400)]
Merge: Perfize FlatBuffer

This PR introduces a bit of a performance improvement to `FlatBuffer` by limiting the number of reallocations for common cases.

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

8 years agolib/core: Stop allocating 1 byte more when initializing a `FlatBuffer` with capacity
Lucas Bajolet [Tue, 3 May 2016 03:27:28 +0000 (23:27 -0400)]
lib/core: Stop allocating 1 byte more when initializing a `FlatBuffer` with capacity

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

8 years agolib/core: Improved running time for reset
Lucas Bajolet [Mon, 2 May 2016 19:32:26 +0000 (15:32 -0400)]
lib/core: Improved running time for reset

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

8 years agolib/core: Improve FlatBuffer re-allocation rate by pre-allocating at least 16 bytes
Lucas Bajolet [Fri, 29 Apr 2016 20:15:24 +0000 (16:15 -0400)]
lib/core: Improve FlatBuffer re-allocation rate by pre-allocating at least 16 bytes

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

8 years agotests: Added new CSV test
Lucas Bajolet [Mon, 2 May 2016 19:03:15 +0000 (15:03 -0400)]
tests: Added new CSV test

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

8 years agosrc: Updated uses of CSV library
Lucas Bajolet [Fri, 29 Apr 2016 20:17:27 +0000 (16:17 -0400)]
src: Updated uses of CSV library

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

8 years agolib/csv: Major rewriting for performance and simplicity
Lucas Bajolet [Fri, 29 Apr 2016 17:43:16 +0000 (13:43 -0400)]
lib/csv: Major rewriting for performance and simplicity

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

8 years agolib/core: `u8char_len` is now public
Lucas Bajolet [Fri, 29 Apr 2016 17:10:22 +0000 (13:10 -0400)]
lib/core: `u8char_len` is now public

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

8 years agolib/core: Added simple write char method to `Writer`
Lucas Bajolet [Fri, 29 Apr 2016 17:10:03 +0000 (13:10 -0400)]
lib/core: Added simple write char method to `Writer`

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

8 years agoMerge: Qualified Class Names
Jean Privat [Tue, 3 May 2016 01:26:26 +0000 (21:26 -0400)]
Merge: Qualified Class Names

After #2034 and #2041 , some of you might had some theories about future episodes. While this is not GoT, I hope the you found that the following is a nice surprise: qualified class names are now understood by the tools.

The specification is the following:

On conflicting class-names, you can use the package_name to qualify the class. i.e. `package_name::ClassName`. This is enough for all public class, since it is the canonical name for them.
For conflicting private classes, the package_name should be enough in most cases. If there is still a conflict, you need to precise also the name of the module. i.e. `package_name::module_name::ClassName`.

Qualified properties is a more complex thing, and since the class is used as a namespace for them, there is statically less property name conflicts (except for classes commonly refined, like Sys maybe). So I plan to put qualified properly names in a boat heading to King’s Landing and let them row.

Pull-Request: #2047
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>

8 years agotests: update sav because new error messages on class name error
Jean Privat [Mon, 2 May 2016 19:58:20 +0000 (15:58 -0400)]
tests: update sav because new error messages on class name error

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

8 years agotests: add `base_name_conflict` to test more conflicting names
Jean Privat [Mon, 2 May 2016 19:55:16 +0000 (15:55 -0400)]
tests: add `base_name_conflict` to test more conflicting names

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

8 years agoMerge: Rubix cube
Jean Privat [Mon, 2 May 2016 23:05:29 +0000 (19:05 -0400)]
Merge: Rubix cube

A simple Rubix Cube library, don't mind the diff, a huge part is just test reuslts :)

It should support all the commands from the Singmaster notation (see [here](http://ruwix.com/the-rubiks-cube/notation/) for more details on the notation)

Note that the big number of specialized top-level functions with ints show in this case how useful a proper Enum system would be :)

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

8 years agoMerge: lib: add logic library
Jean Privat [Mon, 2 May 2016 23:05:12 +0000 (19:05 -0400)]
Merge: lib: add logic library

After cleaning some CTF code.

More code,  like a parser and generation of common format might come

Pull-Request: #2037
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>

8 years agoMerge: Add nitlight and jwrapper to the benchbed
Jean Privat [Mon, 2 May 2016 23:05:07 +0000 (19:05 -0400)]
Merge: Add nitlight and jwrapper to the benchbed

Also improve jwrapper a little

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

8 years agoMerge: nitcatalog: handle local images
Jean Privat [Mon, 2 May 2016 23:05:03 +0000 (19:05 -0400)]
Merge: nitcatalog: handle local images

nitcatalog is extended to detect links to local images, copy the resource in the catalog directory and hijack the generated link.
This should fix #2042 and fix the images in http://nitlanguage.org/catalog/p/tinks.html

Most is done by monkey-patching (aka dirty refinement) since the doc_down model uses an internal private global markdown decorator. I'm not sure what should be the best approach here, and I had to improvise since @Morriar is MIA.

Bonus:

* `file_copy_to` is fixed and do not corrupt binary files (thanks @R4PaSs)
* `tests/test_prog` is used to test the catalog

Pull-Request: #2046
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>

8 years agomodelize_class: use the new `get_mclass_by_id` to identify class refinement
Jean Privat [Mon, 2 May 2016 19:44:00 +0000 (15:44 -0400)]
modelize_class: use the new `get_mclass_by_id` to identify class refinement

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

8 years agomodelbuilder: Add a specific error message for class ambiguities.
Jean Privat [Mon, 2 May 2016 19:43:03 +0000 (15:43 -0400)]
modelbuilder: Add a specific error message for class ambiguities.

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

8 years agomodelbuilder: add (and use) `AQclassid::full_name` for better messages
Jean Privat [Mon, 2 May 2016 19:42:26 +0000 (15:42 -0400)]
modelbuilder: add (and use) `AQclassid::full_name` for better messages

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

8 years agomodelbuilder: split the class_not_found error in a separate function
Jean Privat [Mon, 2 May 2016 19:39:21 +0000 (15:39 -0400)]
modelbuilder: split the class_not_found error in a separate function

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

8 years agotests: Added rubix tests to skip for niti and nitvm
Lucas Bajolet [Mon, 2 May 2016 19:16:17 +0000 (15:16 -0400)]
tests: Added rubix tests to skip for niti and nitvm

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

8 years agotests: update sav because improved error messages on class names
Jean Privat [Mon, 2 May 2016 02:22:38 +0000 (22:22 -0400)]
tests: update sav because improved error messages on class names

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

8 years agotests: use more complex names for `test_model_visitor`
Jean Privat [Mon, 2 May 2016 00:58:10 +0000 (20:58 -0400)]
tests: use more complex names for `test_model_visitor`

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

8 years agotests: add `error_names` and extends the `names` hierarchy
Jean Privat [Mon, 2 May 2016 00:54:04 +0000 (20:54 -0400)]
tests: add `error_names` and extends the `names` hierarchy

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

8 years agomodelbuilder: add `try_get_mclass_by_qid` to handle qualified class names
Jean Privat [Mon, 2 May 2016 00:45:07 +0000 (20:45 -0400)]
modelbuilder: add `try_get_mclass_by_qid` to handle qualified class names

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

8 years agotests: add metadata & content in test_prog to test nitcatalog
Jean Privat [Mon, 2 May 2016 01:21:27 +0000 (21:21 -0400)]
tests: add metadata & content in test_prog to test nitcatalog

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

8 years agonitcatalog: copy local image resources inside the output directory
Jean Privat [Sun, 1 May 2016 18:01:29 +0000 (14:01 -0400)]
nitcatalog: copy local image resources inside the output directory

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

8 years agomodelbuilder: fix hint on bad classnames
Jean Privat [Mon, 2 May 2016 00:42:34 +0000 (20:42 -0400)]
modelbuilder: fix hint on bad classnames

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

8 years agonitc/doc/doc_down: store the current mdoc object in the decorator
Jean Privat [Sun, 1 May 2016 17:37:23 +0000 (13:37 -0400)]
nitc/doc/doc_down: store the current mdoc object in the decorator

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

8 years agonitc/doc/doc_down: make NitdocDecorator public to it can be extended
Jean Privat [Sun, 1 May 2016 17:36:54 +0000 (13:36 -0400)]
nitc/doc/doc_down: make NitdocDecorator public to it can be extended

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