nit.git
5 years agocore: fix typos in doc of CircularArray
Alexis Laferrière [Tue, 24 Jul 2018 22:02:28 +0000 (18:02 -0400)]
core: fix typos in doc of CircularArray

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

5 years agocore: fix typos in union_find
Alexis Laferrière [Tue, 24 Jul 2018 17:52:41 +0000 (13:52 -0400)]
core: fix typos in union_find

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

5 years agoMerge: lib/md5: nitunitize tests
Jean Privat [Tue, 15 May 2018 22:52:05 +0000 (18:52 -0400)]
Merge: lib/md5: nitunitize tests

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

Pull-Request: #2694

5 years agoMerge: lib/base64: nitunize tests
Jean Privat [Tue, 15 May 2018 22:52:04 +0000 (18:52 -0400)]
Merge: lib/base64: nitunize tests

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

Pull-Request: #2693

5 years agoMerge: lib/a_star: nitunitize tests
Jean Privat [Tue, 15 May 2018 22:52:03 +0000 (18:52 -0400)]
Merge: lib/a_star: nitunitize tests

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

Pull-Request: #2692

5 years agoMerge: src/doc/commands: fix test class name for `commands_md`
Jean Privat [Tue, 15 May 2018 16:51:46 +0000 (12:51 -0400)]
Merge: src/doc/commands: fix test class name for `commands_md`

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

Pull-Request: #2689

5 years agoMerge: contrib: generate Makefiles with nitpackage
Jean Privat [Tue, 15 May 2018 16:51:45 +0000 (12:51 -0400)]
Merge: contrib: generate Makefiles with nitpackage

I applied `nitpackage --gen-makefile` (#2662) on contrib:
* generated Makefile for projects without any (76a17aa)
* replaced some existing Makefiles with their generated counterpart (a95be1e)
* manually merged generated rules into existing Makefiles (3b85ec3)

Please consider only these commits as the rest of them belongs to another PRs.

Pull-Request: #2685

5 years agoMerge: contrib: apply nitpackage --gen-ini
Jean Privat [Tue, 15 May 2018 16:51:44 +0000 (12:51 -0400)]
Merge: contrib: apply nitpackage --gen-ini

I ran `nitpackage --gen-ini` on contrib projects.

First of all, I added 3 more accepted keys to nitpackage --check-ini that seem to be used in some projects (04abe90):
* `upstream.apk`
* `upstream.tryit`
* `source.exclude`

I expanded the package `github_merge`, the only one left in the non-expanded form in the Nit project (51df98b).

Then I corrected some `git.directory` keys with incorrect values (a4b53f7). Short note for `src`, I added the trailing `/` to be consistent with all other ini files.

Finally I generated the `package.desc` for all projects from the `mdoc_or_fallback.synopsis` values (051ab50).

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

5 years agoMerge: lib/core: remove BufferedReader
Jean Privat [Tue, 15 May 2018 16:51:43 +0000 (12:51 -0400)]
Merge: lib/core: remove BufferedReader

Since the streams are often already buffered in the libraries we depend
upon, and since it is not used anymore on streams present in the
librarires, we remove it.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

Pull-Request: #2680

5 years agoMerge: nitpackage: generate and check manpages
Jean Privat [Tue, 15 May 2018 16:51:41 +0000 (12:51 -0400)]
Merge: nitpackage: generate and check manpages

This PR adds two new features to nitpackage:

--check-man: check manpages existence and content for packages and executable modules
--gen-man: create manpages for packages and executable modules

As example I added new manpages (91b9839) to `lib/markdown` and `lib/github`.

Please only consider the 6 last commits as the rest belongs to #2652, #2653, #2656, #2657 and #2662.

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

5 years agoMerge: nitpackage: create and check Makefile
Jean Privat [Tue, 15 May 2018 16:51:40 +0000 (12:51 -0400)]
Merge: nitpackage: create and check Makefile

This PR adds two new features to `nitpackage`:
* `--check-makefile`: check Makefiles existence for packages and executable modules
* `--gen-makefile`: create Makefiles for packages and executable modules

As example I added new Makefiles (4f948e3) to all lib/ project if none was found.
I also updated some Makefiles from my projects (dbacfc0).

Please only consider the 4 last commits as the rest belongs to #2652, #2653, #2656 and #2657.

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

5 years agocontrib: merge manually generated Makefiles with existing ones
Alexandre Terrasa [Sun, 13 May 2018 20:34:27 +0000 (16:34 -0400)]
contrib: merge manually generated Makefiles with existing ones

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

5 years agocontrib: replace Makefile form contrib with same rules
Alexandre Terrasa [Sun, 13 May 2018 20:13:58 +0000 (16:13 -0400)]
contrib: replace Makefile form contrib with same rules

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

5 years agocontrib: generate Makefile for projects without any
Alexandre Terrasa [Sun, 13 May 2018 20:10:12 +0000 (16:10 -0400)]
contrib: generate Makefile for projects without any

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

5 years agocontrib: add some manpages generated with `nitpackage`
Alexandre Terrasa [Mon, 14 May 2018 17:47:00 +0000 (13:47 -0400)]
contrib: add some manpages generated with `nitpackage`

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

5 years agolib: add some manpages generated with `nitpackage`
Alexandre Terrasa [Tue, 8 May 2018 22:20:39 +0000 (18:20 -0400)]
lib: add some manpages generated with `nitpackage`

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

5 years agonitpackage: generate and check man pages
Alexandre Terrasa [Tue, 8 May 2018 22:20:18 +0000 (18:20 -0400)]
nitpackage: generate and check man pages

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

5 years agogit: ignore `lib/*/bin`
Alexandre Terrasa [Tue, 15 May 2018 14:04:10 +0000 (10:04 -0400)]
git: ignore `lib/*/bin`

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

5 years agoshare/man: fix `nitmd` path
Alexandre Terrasa [Sun, 13 May 2018 18:51:54 +0000 (14:51 -0400)]
share/man: fix `nitmd` path

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

5 years agolib: add two examples of Makefile generated by `nitpackage`
Alexandre Terrasa [Fri, 11 May 2018 22:20:26 +0000 (18:20 -0400)]
lib: add two examples of Makefile generated by `nitpackage`

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

5 years agonitpackage: generate and check Makefiles
Alexandre Terrasa [Tue, 8 May 2018 15:30:08 +0000 (11:30 -0400)]
nitpackage: generate and check Makefiles

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

5 years agonitpackage: rename phase
Alexandre Terrasa [Tue, 8 May 2018 02:00:28 +0000 (22:00 -0400)]
nitpackage: rename phase

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

5 years agocontrib: generate `package.desc` key for all contrib projects
Alexandre Terrasa [Sun, 13 May 2018 19:07:53 +0000 (15:07 -0400)]
contrib: generate `package.desc` key for all contrib projects

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

5 years agocontrib: fix wrong `git.directory` in some contrib projects
Alexandre Terrasa [Sun, 13 May 2018 19:29:53 +0000 (15:29 -0400)]
contrib: fix wrong `git.directory` in some contrib projects

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

5 years agonitpackage: accept more `package.ini` keys
Alexandre Terrasa [Sun, 13 May 2018 19:30:50 +0000 (15:30 -0400)]
nitpackage: accept more `package.ini` keys

Added:
* `upstream.apk`
* `upstream.tryit`
* `source.exclude`

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

5 years agoMerge: contrib/wiringPi: fix `shift` module name
Jean Privat [Tue, 15 May 2018 11:16:39 +0000 (07:16 -0400)]
Merge: contrib/wiringPi: fix `shift` module name

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

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

5 years agoMerge: contrib/nitiwiki: protect non-nit code blokcs in README
Jean Privat [Tue, 15 May 2018 11:16:38 +0000 (07:16 -0400)]
Merge: contrib/nitiwiki: protect non-nit code blokcs in README

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

Pull-Request: #2683

5 years agoMerge: contrib: use `config` instead of `opts`
Jean Privat [Tue, 15 May 2018 11:16:38 +0000 (07:16 -0400)]
Merge: contrib: use `config` instead of `opts`

Modified two contrib projects to make then use `config`:
* `github_merge`
* `nitiwiki`

They now automatically provide the `--stub-manpage` option from `config`.

Pull-Request: #2686

5 years agoMerge: contrib: fix readmes
Jean Privat [Tue, 15 May 2018 11:16:37 +0000 (07:16 -0400)]
Merge: contrib: fix readmes

Fix some unprotected raw code blocks in contrib READMES.

Pull-Request: #2687

5 years agolib/md5: nitunitize tests
Alexandre Terrasa [Tue, 15 May 2018 02:46:29 +0000 (22:46 -0400)]
lib/md5: nitunitize tests

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

5 years agolib/base64: nitunize tests
Alexandre Terrasa [Tue, 15 May 2018 02:24:33 +0000 (22:24 -0400)]
lib/base64: nitunize tests

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

5 years agolib/a_star: nitunitize tests
Alexandre Terrasa [Tue, 15 May 2018 02:21:47 +0000 (22:21 -0400)]
lib/a_star: nitunitize tests

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

5 years agosrc/doc/commands: fix test class name for `commands_md`
Alexandre Terrasa [Tue, 15 May 2018 00:51:49 +0000 (20:51 -0400)]
src/doc/commands: fix test class name for `commands_md`

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

5 years agocontrib/nitiwiki: use `config` instead of `opts`
Alexandre Terrasa [Mon, 14 May 2018 16:45:41 +0000 (12:45 -0400)]
contrib/nitiwiki: use `config` instead of `opts`

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

5 years agocontrib/github_merge: use `config` instead of `opts`
Alexandre Terrasa [Mon, 14 May 2018 16:29:09 +0000 (12:29 -0400)]
contrib/github_merge: use `config` instead of `opts`

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

5 years agocontrib: expand package `github_merge`
Alexandre Terrasa [Sun, 13 May 2018 19:18:24 +0000 (15:18 -0400)]
contrib: expand package `github_merge`

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

5 years agocontrib/sort_downloads: protect README doc units
Alexandre Terrasa [Mon, 14 May 2018 18:12:08 +0000 (14:12 -0400)]
contrib/sort_downloads: protect README doc units

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

5 years agocontrib/nitin: protect README doc units
Alexandre Terrasa [Mon, 14 May 2018 18:11:56 +0000 (14:11 -0400)]
contrib/nitin: protect README doc units

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

5 years agocontrib/brainfuck: protect README doc units
Alexandre Terrasa [Mon, 14 May 2018 18:11:49 +0000 (14:11 -0400)]
contrib/brainfuck: protect README doc units

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

5 years agocontrib/nitiwiki: protect non-nit code blocks in README
Alexandre Terrasa [Sun, 13 May 2018 20:35:44 +0000 (16:35 -0400)]
contrib/nitiwiki: protect non-nit code blocks in README

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

5 years agocontrib/wiringPi: fix `shift` module name
Alexandre Terrasa [Sun, 13 May 2018 18:48:46 +0000 (14:48 -0400)]
contrib/wiringPi: fix `shift` module name

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

5 years agolib/core: remove BufferedReader
Lucas Bajolet [Sun, 13 May 2018 13:55:27 +0000 (09:55 -0400)]
lib/core: remove BufferedReader

Since the streams are often already buffered in the libraries we depend
upon, and since it is not used anymore on streams present in the
librarires, we remove it.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agoMerge: lib/config: better tool configuration
Jean Privat [Sat, 12 May 2018 01:10:41 +0000 (21:10 -0400)]
Merge: lib/config: better tool configuration

This PR reworks some aspects of the `lib/config`:
* Add option `-?` as help
* Introduce `--stub-man` option (almost the same thing than in `ToolContext`)
* Make `nitmd` use `config` instead of `opts`
* Define a better `tool_description` for `github/loader`

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

5 years agoMerge: doc/commands: introduce Markdown rendering for commands
Jean Privat [Sat, 12 May 2018 01:10:40 +0000 (21:10 -0400)]
Merge: doc/commands: introduce Markdown rendering for commands

This PR introduces Markdown rendering for all DocCommands.

Also adds tests.

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

5 years agoMerge: Trace system
Jean Privat [Sat, 12 May 2018 01:10:40 +0000 (21:10 -0400)]
Merge: Trace system

To install lttng: https://lttng.org/docs/v2.10/#doc-installing-lttng

To compile using the trace system: add -t or --trace

To test tracing some instances :
lttng create "Nom de la session"
lttng enable-event --userspace Nit_Compiler:Object_Instance
lttng start
--> run your program
lttng stop

To read your CTF trace file:
babeltrace ~/lttng-traces/nom_de_la_session

define TRACEPOINT_INCLUDE "/home/olivier/Bureau/nit/src/nit_compile/traces.h"
This instruction is located into traces.h. You have to adapt it with your specific path.
The dynamical version is the object of the next PR.

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

5 years agotests: fix tests related to new config options display
Alexandre Terrasa [Fri, 11 May 2018 22:07:02 +0000 (18:07 -0400)]
tests: fix tests related to new config options display

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

5 years agoMerge: macOS: skip one of the nitpm tests because of locale issues
Jean Privat [Fri, 11 May 2018 20:01:27 +0000 (16:01 -0400)]
Merge: macOS: skip one of the nitpm tests because of locale issues

The test `nitpm_arg3` exposes an output from Git. It looks like there is locale issue on the macOS CI server changing the output and breaking the tests.

Test diff:
~~~
--- sav//nitpm_args3.res 2018-04-05 22:14:54.000000000 -0400
+++ out/nitpm_args3.res 2018-05-11 02:59:58.000000000 -0400
@@ -1 +1 @@
-Already up-to-date.
+Already up to date.
~~~

I didn't find a clear cause after a quick investigation. This PR as a temporary workaround, feel free to investigate and PR a real fix!

Pull-Request: #2675

5 years agoMerge: opportunity: add a docker-compose.yml file
Jean Privat [Fri, 11 May 2018 20:01:21 +0000 (16:01 -0400)]
Merge: opportunity: add a docker-compose.yml file

Pull-Request: #2677

5 years agoMerge: Small improvements on the oot.sh script
Jean Privat [Fri, 11 May 2018 20:01:18 +0000 (16:01 -0400)]
Merge: Small improvements on the oot.sh script

Pull-Request: #2676

5 years agoMerge: File no buffered
Jean Privat [Fri, 11 May 2018 20:01:08 +0000 (16:01 -0400)]
Merge: File no buffered

Still as part of the Stream refactor, this commit removes the BufferedReader dependency for FileReader.

Note: last commit only to review, the previous one is from #2648

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

5 years agoMerge: Added HTTP METHODS to CurlHTTPRequest
Jean Privat [Fri, 11 May 2018 20:01:08 +0000 (16:01 -0400)]
Merge: Added HTTP METHODS to CurlHTTPRequest

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

5 years agoMerge: Bitmap fix missing checks
Jean Privat [Fri, 11 May 2018 20:01:06 +0000 (16:01 -0400)]
Merge: Bitmap fix missing checks

Some checks were missing after fixing some warnings in PR #2658, we add these checks here.

Note: the last commit only is relevant, the other comes from #2658

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

5 years agoMerge: lib/socket: remove BufferedReader superclass
Jean Privat [Fri, 11 May 2018 20:01:05 +0000 (16:01 -0400)]
Merge:  lib/socket: remove BufferedReader superclass

Since BufferedReader is scheduled for removal, we remove it as superclass from the TCPSocket.

As the TCPSocket will be buffered at the system-level, it is not a big problem for performance.

Note: Last commit is to be reviewed only, the others are from #2648

Pull-Request: #2665

5 years agoMerge: Fix Reader::read
Jean Privat [Fri, 11 May 2018 20:01:04 +0000 (16:01 -0400)]
Merge: Fix Reader::read

With the stream refactor being developed and tested alongside, some buggy behaviours are being discovered.
This PR fixes one of such, where calling read on a dead stream caused the program to segfault.

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

5 years agolib/core: add blocking eof implementation
Lucas Bajolet [Wed, 9 May 2018 01:54:07 +0000 (21:54 -0400)]
lib/core: add blocking eof implementation

eof is a problematic operation for Streams as its state may be decided
by reading input (in sockets for instance).

Because of that, operations relying on it may read one extra byte at the
end of a file, causing the apparition of bad characters (null byte, or
replacement character).

By changing the semantic of eof and making it blocking, we ensure that
querying eof will always produce the appropriate error.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agolib/core: fix read_bytes_to_cstring implementation
Lucas Bajolet [Thu, 10 May 2018 21:49:47 +0000 (17:49 -0400)]
lib/core: fix read_bytes_to_cstring implementation

When reading bytes from both the lookahead and a source, the lookahead
bytes were not kept in the cstring and we re-written by the
raw_read_bytes after that.

This commit fixes that behaviour.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agolib/core: remove BufferedReader as file superclass
Lucas Bajolet [Mon, 7 May 2018 14:48:15 +0000 (10:48 -0400)]
lib/core: remove BufferedReader as file superclass

Since files are already buffered at the libc-level, we do not need to
have a BufferedReader on top of it.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agoopportunity: add a docker-compose.yml file
Jean Privat [Fri, 11 May 2018 16:38:06 +0000 (12:38 -0400)]
opportunity: add a docker-compose.yml file

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

5 years agoadd the trace system with a first test which is instance tracing
olivierschirm [Wed, 9 May 2018 20:09:22 +0000 (16:09 -0400)]
add the trace system with a first test which is instance tracing

Signed-off-by: olivierschirm <olive.schirm@gmail.com>

5 years agocontrib/oot.sh: allow an optional list argument
Jean Privat [Fri, 11 May 2018 15:12:52 +0000 (11:12 -0400)]
contrib/oot.sh: allow an optional list argument

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

5 years agocontrib/oot.sh: do not error if no makefile
Jean Privat [Fri, 11 May 2018 15:11:54 +0000 (11:11 -0400)]
contrib/oot.sh: do not error if no makefile

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

5 years agolib/github: define better `tool_description` for loader
Alexandre Terrasa [Tue, 8 May 2018 22:19:53 +0000 (18:19 -0400)]
lib/github: define better `tool_description` for loader

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

5 years agolib/markdown: nitmd use `config` instead of `options`
Alexandre Terrasa [Tue, 8 May 2018 22:19:25 +0000 (18:19 -0400)]
lib/markdown: nitmd use `config` instead of `options`

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

5 years agolib/config: introduce --stub-man option
Alexandre Terrasa [Tue, 8 May 2018 22:18:52 +0000 (18:18 -0400)]
lib/config: introduce --stub-man option

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

5 years agolib/config: add `-?` option as help
Alexandre Terrasa [Tue, 8 May 2018 02:54:00 +0000 (22:54 -0400)]
lib/config: add `-?` option as help

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

5 years agodoc/commands: introduce Markdown rendering for commands
Alexandre Terrasa [Thu, 3 May 2018 16:42:03 +0000 (12:42 -0400)]
doc/commands: introduce Markdown rendering for commands

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

5 years agomacOS: skip one of the nitpm tests because of locale issues
Alexis Laferrière [Fri, 11 May 2018 14:41:45 +0000 (10:41 -0400)]
macOS: skip one of the nitpm tests because of locale issues

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

5 years agoMerge: docker: nitpm requires libcurl, move it up from `full`
Jean Privat [Fri, 11 May 2018 14:33:36 +0000 (10:33 -0400)]
Merge: docker: nitpm requires libcurl, move it up from `full`

This PR should fix the compilation of the nitlang/nit Docker which was broken since adding nitpm.

See: https://hub.docker.com/r/nitlang/nit/builds/bgtphmftqbdp9o7eqhqzn9f/

I've activated email alerts on hub.docker.com to hopefully catch these problems sooner next time.

Pull-Request: #2672

5 years agolib/websocket: refactor websocket as a Protocol
Lucas Bajolet [Wed, 9 May 2018 16:07:40 +0000 (12:07 -0400)]
lib/websocket: refactor websocket as a Protocol

Websocket can be re-implemented as a Protocol to be implemented atop a
TCP stream.

This refactor should be more memory-efficient when handling incoming
data.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agolib/socket: remove BufferedReader superclass
Lucas Bajolet [Tue, 8 May 2018 19:26:53 +0000 (15:26 -0400)]
lib/socket: remove BufferedReader superclass

Since BufferedReader is scheduled for removal, we remove it as a
superclass from the TCPSocket.

As the TCPSocket will be buffered at the system-level, it is not a big
problem for performance.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agolib/core: add protocols for decorator streams
Lucas Bajolet [Wed, 9 May 2018 17:18:51 +0000 (13:18 -0400)]
lib/core: add protocols for decorator streams

Protocol are a class of streams designed to be decorators over others
and provide a high-level interface to protocols.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agodocker: nitpm requires libcurl, move it up from `full`
Alexis Laferrière [Fri, 11 May 2018 11:26:47 +0000 (07:26 -0400)]
docker: nitpm requires libcurl, move it up from `full`

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

5 years agolib/core: add failsafe to UTF8Codec::decode_string
Lucas Bajolet [Fri, 11 May 2018 00:50:14 +0000 (20:50 -0400)]
lib/core: add failsafe to UTF8Codec::decode_string

Calling decode_string on the UTF-8 codec with a negative legth would
cause memmove to crash the program with a segfault.

Adding an assert gives more information on what went wrong and will help
investigate future bugs.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agolib/core: fix Reader::read
Lucas Bajolet [Fri, 11 May 2018 00:48:31 +0000 (20:48 -0400)]
lib/core: fix Reader::read

Reader::read would crash if trying to read from an empty socket, as the
codec::decode_string would be called with a negative length.

We add a failsafe to prevent that.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agolib/bitmap: fix unchecked error while reading bytes
Lucas Bajolet [Tue, 8 May 2018 13:57:33 +0000 (09:57 -0400)]
lib/bitmap: fix unchecked error while reading bytes

The `read_byte` method from `Reader` may return a negative int if an
error is encountered while reading.

This was not checked in lib/bitmap, we therefore add it.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agolib/bitmap: fix warnings
Alexandre Terrasa [Tue, 8 May 2018 13:43:10 +0000 (09:43 -0400)]
lib/bitmap: fix warnings

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

5 years agoMerge: android: remove the deprecated armeabi target platform
Jean Privat [Fri, 11 May 2018 03:14:25 +0000 (23:14 -0400)]
Merge: android: remove the deprecated armeabi target platform

Android NDK tools do not support the armeabi target platform anymore, breaking the compilation of all Nit app for Android. This PR removes this target, fixing our compilation issues. This platform version should not be active anywhere, it was widely replaced by armeabi-v7a.

Unless you update the Android SDK tool, compiling Nit apps for Android should still work on your machine and the CI server. However, it fails on the Nit docker, as with:
https://gitlab.com/xymus/darpg/-/jobs/67649353
https://gitlab.com/Skyline76/memory_gamnit/-/jobs/67571796

Pull-Request: #2671

5 years agoMerge: lib/crypto: add in-place xor cipher on CStrings
Jean Privat [Fri, 11 May 2018 03:14:18 +0000 (23:14 -0400)]
Merge: lib/crypto: add in-place xor cipher on CStrings

The xor operation as defined in xor_ciphers lacked a performance-aware
version on byte sequences.

This commit adds a fast version to perform it on a CString.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

Pull-Request: #2669

5 years agoMerge: lib: add `package.desc` keys to the `package.ini` file of most of the packages...
Jean Privat [Fri, 11 May 2018 03:13:52 +0000 (23:13 -0400)]
Merge: lib: add `package.desc` keys to the `package.ini` file of most of the packages in `lib`

This PR adds a `package.desc` key to all `package.ini` files into `lib/`.

For most of them the description is imported from the `mdoc_or_fallback.synopsis` with some light modifications (removing the starting `#` and the trailing `.`).

After this automated fix, 5 packages still missed the `package.desc` key:
* `dummy_array`
* `filter_stream`
* `graph`
* `mnit`
* `postgresql`

I manually added the key for `graph` and `postgresql`, so after this PR only 3 packages still miss the key:
* `dummy_array`
* `filter_stream`
* `mnit`

Pull-Request: #2667

5 years agoMerge: lib/core/text: add memset to `CString`
Jean Privat [Fri, 11 May 2018 03:13:51 +0000 (23:13 -0400)]
Merge: lib/core/text: add memset to `CString`

Memset is an operation used for setting bytes to a particular value.

Since it was not defined on CStrings, we add it.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

Pull-Request: #2668

5 years agoandroid: remove the deprecated armeabi target
Alexis Laferrière [Fri, 11 May 2018 02:01:35 +0000 (22:01 -0400)]
android: remove the deprecated armeabi target

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

5 years agoMerge: lib/core: provide default codec-aware read_char
Jean Privat [Thu, 10 May 2018 22:46:06 +0000 (18:46 -0400)]
Merge: lib/core: provide default codec-aware read_char

Previous implementations of read_char were unaware of codec issues, and
used to read a byte and convert it to a code point.

For ASCII characters this was enough, but once unicode characters were
read on a char-by-char basis, wrong characters would appear.

This commit fixes this issue by using the Codec API to read a character
intelligently, and properly support multibyte encodings.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

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

5 years agoMerge: doc/commands: introduce `main` related commands
Jean Privat [Thu, 10 May 2018 22:46:06 +0000 (18:46 -0400)]
Merge: doc/commands: introduce `main` related commands

This PR introduce new doc commands related to executable files:
* `CmdMains`: list all executable files from a package
* `CmdMainCompile`: return the `nitc` command to compile an executable file
* `CmdTesting`: return the `nitunit` command to test a package
* `CmdManSynopsis`: return the command synopsis from its manpage
* `CmdManOptions`: return the command options descriptions from its manpage

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

5 years agoMerge: json: rename and improve the quick and easy `deserialize_json`
Jean Privat [Thu, 10 May 2018 22:46:05 +0000 (18:46 -0400)]
Merge: json: rename and improve the quick and easy `deserialize_json`

Rename the service `String::from_json_string` to a nicer `deserialize_json`. I believe that the old name was counter-intuitive and may explain why the method was used so rarely/never.

Add the argument `static_type` to `deserialize_json` to limit the type of objects that can be deserialized. This argument is passed directly to the JSON deserializer.

The method `deserialize_json` still prints errors to the console, so it should be used for quick prototypes or scripts.

This could make prettier and safer examples in #2655.

Pull-Request: #2664

5 years agolib/core: provide default codec-aware read_char
Lucas Bajolet [Mon, 7 May 2018 14:45:21 +0000 (10:45 -0400)]
lib/core: provide default codec-aware read_char

Previous implementations of read_char were unaware of codec issues, and
used to read a byte and convert it to a code point.

For ASCII characters this was enough, but once unicode characters were
read on a char-by-char basis, wrong characters would appear.

This commit fixes this issue by using the Codec API to read a character
intelligently, and properly support multibyte encodings.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agoniti: fix CString::fast_cstring semantics
Lucas Bajolet [Tue, 8 May 2018 16:01:30 +0000 (12:01 -0400)]
niti: fix CString::fast_cstring semantics

The old implementation of CString::fast_cstring used to create a new
CString instance instead of sharing the underlying buffer.

This in turn caused code relying on this semantic to fail as the memory
was not re-initialized properly.

This commit fixes this behaviour by introducing a new cstring
constructor specific for the VM and Interpreter.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agotests: fix tests related to test_prog
Alexandre Terrasa [Tue, 8 May 2018 01:56:15 +0000 (21:56 -0400)]
tests: fix tests related to test_prog

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

5 years agodoc/commands: term handles `commands_main`
Alexandre Terrasa [Wed, 2 May 2018 23:34:43 +0000 (19:34 -0400)]
doc/commands: term handles `commands_main`

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

5 years agodoc/commands: render `commands_main` as JSON
Alexandre Terrasa [Wed, 2 May 2018 23:20:39 +0000 (19:20 -0400)]
doc/commands: render `commands_main` as JSON

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

5 years agodoc/commands: render `commands_main` as HTML
Alexandre Terrasa [Wed, 2 May 2018 23:20:19 +0000 (19:20 -0400)]
doc/commands: render `commands_main` as HTML

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

5 years agodoc/commands: parse `commands_main`
Alexandre Terrasa [Wed, 2 May 2018 23:18:04 +0000 (19:18 -0400)]
doc/commands: parse `commands_main`

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

5 years agodoc/commands: introduce `commands_main`, commands about main programs
Alexandre Terrasa [Wed, 2 May 2018 23:17:26 +0000 (19:17 -0400)]
doc/commands: introduce `commands_main`, commands about main programs

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

5 years agolib/crypto: add in-place xor cipher on CStrings
Lucas Bajolet [Thu, 10 May 2018 18:18:49 +0000 (14:18 -0400)]
lib/crypto: add in-place xor cipher on CStrings

The xor operation as defined in xor_ciphers lacked a performance-aware
version on byte sequences.

This commit adds a fast version to perform it on a CString.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agoAdded HTTP METHODS to CurlHTTPRequest
Matthieu Le Guellaut [Thu, 10 May 2018 15:08:40 +0000 (11:08 -0400)]
Added HTTP METHODS to CurlHTTPRequest

Signed-off-by: Matthieu Le Guellaut <leguellaut.matthieu@gmail.com>

5 years agolib/core/text: add memset to `CString`
Lucas Bajolet [Thu, 10 May 2018 18:17:39 +0000 (14:17 -0400)]
lib/core/text: add memset to `CString`

Memset is an operation used for setting bytes to a particular value.

Since it was not defined on CStrings, we add it.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

5 years agolib: manually add `package.desc` keys to some packages
Alexandre Terrasa [Thu, 10 May 2018 16:37:24 +0000 (12:37 -0400)]
lib: manually add `package.desc` keys to some packages

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

5 years agolib: generate `package.desc` keys to all packages
Alexandre Terrasa [Thu, 10 May 2018 16:31:08 +0000 (12:31 -0400)]
lib: generate `package.desc` keys to all packages

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

5 years agodoc/commands: allow NitUnit entities in model view
Alexandre Terrasa [Wed, 2 May 2018 23:19:49 +0000 (19:19 -0400)]
doc/commands: allow NitUnit entities in model view

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

5 years agomodel_collect: collect all mmodules for a mgroup
Alexandre Terrasa [Mon, 7 May 2018 21:02:21 +0000 (17:02 -0400)]
model_collect: collect all mmodules for a mgroup

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

5 years agotests/test_prog: add a dummy test suite
Alexandre Terrasa [Wed, 2 May 2018 23:16:30 +0000 (19:16 -0400)]
tests/test_prog: add a dummy test suite

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