nit.git
7 years agojson: use `write_char c` instead of `write c.to_s`
Jean Privat [Thu, 16 Feb 2017 14:39:52 +0000 (09:39 -0500)]
json: use `write_char c` instead of `write c.to_s`

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

7 years agoMerge: Windows: last changes for a working bootstrap
Jean Privat [Thu, 16 Feb 2017 13:54:40 +0000 (08:54 -0500)]
Merge: Windows: last changes for a working bootstrap

This PR tweaks the generated Makefile so it works under Windows and silences the excessive warnings when casting ints to pointers, which is used to optimize `Int`, `Char` and `Bool`. And, to fix the heuristic that finds the Nit dir, this PR modifies two methods to support Windows path separator `\` and the PATH env var separator `;`.

These should be the last changes to get a working bootstrap on Windows using msys2/mingw64 tools. Once we regen c_src, you can clone and make Nit from Windows by following the first guide at: http://nitlanguage.org/windows.html Using msys2/mingw64 allows to compile native Windows apps using GNU tools, so the resulting program is an exe file that can use any Windows .dll file and show standard Windows windows.

These changes are far from fixing all issues for running Nit on Windows. However, a working bootstrap will simplify future incremental improvements and will allow detecting regressions with automated testing.

Pull-Request: #2368
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

7 years agoMerge: new module annotation `is generated`
Jean Privat [Thu, 16 Feb 2017 13:54:38 +0000 (08:54 -0500)]
Merge: new module annotation `is generated`

This annotation has no effect on the semantic.
is only intended on software engineering software to discriminate computer-generated modules from human-written ones.

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

7 years agolib/github: fix api pull request
Alexandre Terrasa [Mon, 13 Feb 2017 02:51:46 +0000 (21:51 -0500)]
lib/github: fix api pull request

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

7 years agolib/github: fix api milestone
Alexandre Terrasa [Mon, 13 Feb 2017 02:51:39 +0000 (21:51 -0500)]
lib/github: fix api milestone

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

7 years agolib/github: fix Commit api for users
Alexandre Terrasa [Fri, 18 Nov 2016 22:53:38 +0000 (17:53 -0500)]
lib/github: fix Commit api for users

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

7 years agolib/github/curl: fix error message matching
Alexandre Terrasa [Fri, 18 Nov 2016 22:53:11 +0000 (17:53 -0500)]
lib/github/curl: fix error message matching

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

7 years agolib/json/serialization: fix serialization of first attribute
Alexandre Terrasa [Fri, 18 Nov 2016 22:53:05 +0000 (17:53 -0500)]
lib/json/serialization: fix serialization of first attribute

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

7 years agolib/json/store: fix object paths
Alexandre Terrasa [Fri, 18 Nov 2016 22:52:57 +0000 (17:52 -0500)]
lib/json/store: fix object paths

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

7 years agolib/popcorn: add response handler for csv documents
Alexandre Terrasa [Sun, 12 Feb 2017 03:13:45 +0000 (22:13 -0500)]
lib/popcorn: add response handler for csv documents

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

7 years agolib/nitcorn: add some media types
Alexandre Terrasa [Sun, 12 Feb 2017 03:13:18 +0000 (22:13 -0500)]
lib/nitcorn: add some media types

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

7 years agocore: simplify_path supports Windows style path
Alexis Laferrière [Fri, 10 Feb 2017 06:32:31 +0000 (22:32 -0800)]
core: simplify_path supports Windows style path

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

7 years agotoolcontext: support Windows PATH separator ';'
Alexis Laferrière [Fri, 10 Feb 2017 06:16:30 +0000 (22:16 -0800)]
toolcontext: support Windows PATH separator ';'

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

7 years agonitc: silence pointer to int cast warnings on Windows
Alexis Laferrière [Fri, 10 Feb 2017 04:03:25 +0000 (23:03 -0500)]
nitc: silence pointer to int cast warnings on Windows

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

7 years agonitc: link with pcreposix but not rt on Windows when using mingw64
Alexis Laferrière [Fri, 28 Oct 2016 00:42:02 +0000 (20:42 -0400)]
nitc: link with pcreposix but not rt on Windows when using mingw64

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

7 years agonitc: use '> nul' on windows
Alexis Laferrière [Tue, 16 Aug 2016 13:29:38 +0000 (09:29 -0400)]
nitc: use '> nul' on windows

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

7 years agoMerge: Use `UInt32` to manipulate Unicode chars and support 32 bits platforms
Jean Privat [Fri, 10 Feb 2017 16:00:14 +0000 (11:00 -0500)]
Merge: Use `UInt32` to manipulate Unicode chars and support 32 bits platforms

Unicode support was broken on 32 bits platforms and anywhere a C `long` was on 32 bits (such as 64 bits Windows). This caused issues when compiling Nit tools.

This PR modifies the critical code in order to use `UInt32` instead of `Int` to fit all the 32 bits of Unicode chars. To do so, the first commit inverts the dependency order of the modules `fixed_int` and `text` so that `text` becomes a client of `fixed_int`. Also, update how constants are declared and fix a few implicit cast warnings.

Fix Debian 32 bits support #2355 after a c_src regen.

Fix #1945 Unicode support on iOS.

Allows to bootstrap under Windows with other minor changes (for another PR).

Reported-by: Alexandre Blondin Massé <alexandre.blondin.masse@gmail.com>

Pull-Request: #2363

7 years agoMerge: improve AST dump
Jean Privat [Fri, 10 Feb 2017 16:00:07 +0000 (11:00 -0500)]
Merge: improve AST dump

The debug method `ANode.dump_tree` is now more versatile and powerful:

* it can hide tokens (and others non useful nodes)
* it can display code line along with the AST
* it can display model information (through refinement in modelize and semantize modules)
* it uses some color so the output is more readable

Eg: for the code

~~~nit
var a: nullable Object = "Hello".substring(1,3)
print "{a or else "?"}"
~~~

the AST dumped is

~~~
1 var a: nullable Object = "Hello".substring(1,3)
AMainMethPropdef  @test_expr.nit:1,1--2,23
`--ABlockExpr  @test_expr.nit:1,1--2,23
   |--AVardeclExpr :nullable Object @test_expr.nit:1,1--47
   |  |--AType :nullable Object @test_expr.nit:1,8--22
   |  `--ACallExpr :String call=String.abstract_text$Text$substring(from: Int, count: Int): String @test_expr.nit:1,26--47
   |     |--AStringExpr :String @test_expr.nit:1,26--32
   |     `--AParExprs  @test_expr.nit:1,43--47
   |        |--AIntegerExpr :Int @test_expr.nit:1,44
   |        `--AIntegerExpr :Int @test_expr.nit:1,46
2 print "{a or else "?"}"
   `--ACallExpr  call=Sys.file$Sys$print(object: Object) @test_expr.nit:2,1--23
      |--AImplicitSelfExpr :Sys @test_expr.nit:2,1
      `--AListExprs  @test_expr.nit:2,7--23
         `--ASuperstringExpr :String @test_expr.nit:2,7--23
            |--AStartStringExpr :String @test_expr.nit:2,7--8
            |--AOrElseExpr :Object @test_expr.nit:2,9--21
            |  |--AVarExpr :nullable Object @test_expr.nit:2,9
            |  `--AStringExpr :String @test_expr.nit:2,19--21
            `--AEndStringExpr :String @test_expr.nit:2,22--23
~~~

Pull-Request: #2364

7 years agoMerge: mongo::queries: add unwind method
Jean Privat [Fri, 10 Feb 2017 16:00:00 +0000 (11:00 -0500)]
Merge: mongo::queries: add unwind method

Also fix `op` method so it matches the specification in the comment

Pull-Request: #2362

7 years agotests: update nitserial & nitresful sav files with 'generated'
Jean Privat [Fri, 10 Feb 2017 13:40:10 +0000 (08:40 -0500)]
tests: update nitserial & nitresful sav files with 'generated'

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

7 years agonitc: use is_generated in various tools and generated files
Jean Privat [Fri, 10 Feb 2017 13:39:25 +0000 (08:39 -0500)]
nitc: use is_generated in various tools and generated files

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

7 years agonitc: add new module annotation `is generated`
Jean Privat [Fri, 10 Feb 2017 13:28:05 +0000 (08:28 -0500)]
nitc: add new module annotation `is generated`

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

7 years agotests: update sav for test_parser
Jean Privat [Fri, 10 Feb 2017 01:30:26 +0000 (20:30 -0500)]
tests: update sav for test_parser

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

7 years agoMerge: nitrestful: async services and deserialize plain JSON arguments
Jean Privat [Fri, 10 Feb 2017 00:49:01 +0000 (19:49 -0500)]
Merge: nitrestful: async services and deserialize plain JSON arguments

This PR brings new features to the generated RESTful services: asynchronous RESTful methods, deserialization of plain JSON objects and more.

Using the annotation and argument `is restful(async)` triggers a method to be executed asynchronously when invoked by an HTTP request. Each RESTful call to this method will be executed by the `thread_pool` attribute of the receiving `RestfulAction`. As such, careful attention should be paid to its code to make sure that it works in parallel to the rest of the services and to other instances/threads of itself. The `thread_pool` can be customized with the desired number of threads and it can also be shared with other services.

Arguments of the RESTful methods are deserialized from JSON format. This PR applies the latest features of the deserialization services and uses the static parameter types as a heuristic to guess the Nit type the incoming data. This is also safer as only subclasses of the static type will be deserialized.

The code generated by nitrestful now considers all RESTful methods in order of declaration. This means that many methods can answer to the same `foo` name, but only the first implementation accepting the HTTP method and the type of the arguments will be executed.

As support, this PR also adds threads support to libevent, handles signal interruptions in `Float::sleep`, makes the `ThreadPool` a bit more permissive, improves support of plain JSON map object and adds a test for the nitrestful example.

Pull-Request: #2360
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Reviewed-by: Jean Privat <jean@pryen.org>

7 years agonitc: test_parser use dump_tree instead of an adhoc treeprinter
Jean Privat [Thu, 9 Feb 2017 18:15:37 +0000 (13:15 -0500)]
nitc: test_parser use dump_tree instead of an adhoc treeprinter

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

7 years agoios: remove temporary Unicode fix
Alexis Laferrière [Thu, 9 Feb 2017 18:20:04 +0000 (13:20 -0500)]
ios: remove temporary Unicode fix

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

7 years agonitc: explicitly cast long to int
Alexis Laferrière [Wed, 8 Feb 2017 08:32:19 +0000 (03:32 -0500)]
nitc: explicitly cast long to int

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

7 years agonitc: fix large int constants
Alexis Laferrière [Wed, 8 Feb 2017 07:14:32 +0000 (02:14 -0500)]
nitc: fix large int constants

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

7 years agotext: use UInt32 to manipulate chars
Alexis Laferrière [Wed, 8 Feb 2017 06:51:21 +0000 (01:51 -0500)]
text: use UInt32 to manipulate chars

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

7 years agonitc: dump_tree can display the lines of the source-code
Jean Privat [Thu, 9 Feb 2017 18:14:39 +0000 (13:14 -0500)]
nitc: dump_tree can display the lines of the source-code

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

7 years agolib/ordered_tree: factorize `write_line` so subclasses can redefine it.
Jean Privat [Thu, 9 Feb 2017 18:13:16 +0000 (13:13 -0500)]
lib/ordered_tree: factorize `write_line` so subclasses can redefine it.

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

7 years agonitc: typing and modelbuilder extends dump_info
Jean Privat [Thu, 9 Feb 2017 17:08:14 +0000 (12:08 -0500)]
nitc: typing and modelbuilder extends dump_info

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

7 years agonitc: ASTDump exposes color helpers
Jean Privat [Thu, 9 Feb 2017 17:07:17 +0000 (12:07 -0500)]
nitc: ASTDump exposes color helpers

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

7 years agonitc: ASTDump can display aditionnal information
Jean Privat [Thu, 9 Feb 2017 17:06:46 +0000 (12:06 -0500)]
nitc: ASTDump can display aditionnal information

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

7 years agonitc: ANode::dump_tree can skip structural nodes
Jean Privat [Thu, 9 Feb 2017 17:05:52 +0000 (12:05 -0500)]
nitc: ANode::dump_tree can skip structural nodes

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

7 years agonitc: add ANode::is_structural
Jean Privat [Thu, 9 Feb 2017 17:05:13 +0000 (12:05 -0500)]
nitc: add ANode::is_structural

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

7 years agonitc: add Location::get_line
Jean Privat [Thu, 9 Feb 2017 17:04:28 +0000 (12:04 -0500)]
nitc: add Location::get_line

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

7 years agocore: invert dependencies between `text` and `fixed_ints`
Alexis Laferrière [Wed, 8 Feb 2017 06:27:09 +0000 (01:27 -0500)]
core: invert dependencies between `text` and `fixed_ints`

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

7 years agomongo: add query unwind stage
Alexandre Terrasa [Wed, 8 Feb 2017 04:53:25 +0000 (23:53 -0500)]
mongo: add query unwind stage

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

7 years agomongo: fix query op name to follow the comment/spec
Alexandre Terrasa [Wed, 8 Feb 2017 04:50:52 +0000 (23:50 -0500)]
mongo: fix query op name to follow the comment/spec

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

7 years agoMerge: nitunit: fix before and after methods
Jean Privat [Mon, 6 Feb 2017 13:39:51 +0000 (08:39 -0500)]
Merge: nitunit: fix before and after methods

Before and after method were not actually called in the test suite process.

This PR enables the compilation and run of these methods.

The new behavior is: if the `before_module` test case fails, all the test cases and the `after_module` are skipped and marked as failed.

Pull-Request: #2359
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>

7 years agoMerge: macOS: update realtime lib for Sierra
Jean Privat [Mon, 6 Feb 2017 13:39:19 +0000 (08:39 -0500)]
Merge: macOS: update realtime lib for Sierra

The latest version of macOS, Sierra, defines the functions `clock_gettime` and `clock_getres` which were previously missing. This PR adds support for Sierra while preserving compatibility with El Capitan using a simple heuristic to either use the system provided functions or define them locally.

Reported-by: Marie-Pier Lessard @mplessard

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

7 years agoMerge: nitc: inject importation
Jean Privat [Mon, 6 Feb 2017 13:39:02 +0000 (08:39 -0500)]
Merge: nitc: inject importation

Extends the nitc code so a phase can inject new submodules.

The main new method the this PR is `ModelBuilder::inject_module_subimportation` that must be used during the analysis on a module.

Up to now, the module hierarchy was fixed and built by the loader before any phases are run.
The basic way was: 1. load the main module, 2. load its imported modules recursively and build the hierarchy, 3. run the phases on all the loaded modules from the most general to the most specific (top-down)
Now the phases can also extends the module hierarchy while running some phases.
This cause the following changes:
* `run_phase` use a work-list (instead of a simple loop)
* new modules can pop up even for the main module of a program, so a fictive main module is always created
* conditional_importations is extended to be used to by inject_module_subimportation.

Pull-Request: #2357
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

7 years agonitcorn: add test for nitrestful
Alexis Laferrière [Thu, 2 Feb 2017 21:32:31 +0000 (16:32 -0500)]
nitcorn: add test for nitrestful

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

7 years agonitcorn: update restful example with an async method and complex data type
Alexis Laferrière [Fri, 14 Oct 2016 18:42:33 +0000 (14:42 -0400)]
nitcorn: update restful example with an async method and complex data type

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

7 years agonitcorn: intro module to simplify pthreads support
Alexis Laferrière [Sun, 16 Oct 2016 14:06:58 +0000 (10:06 -0400)]
nitcorn: intro module to simplify pthreads support

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

7 years agonitrestful & lib: use static type to limit and as heuristic at deserialization
Alexis Laferrière [Sat, 15 Oct 2016 00:58:55 +0000 (20:58 -0400)]
nitrestful & lib: use static type to limit and as heuristic at deserialization

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

7 years agonitrestful: use mclassdef instead of mclass
Alexis Laferrière [Sat, 15 Oct 2016 00:58:29 +0000 (20:58 -0400)]
nitrestful: use mclassdef instead of mclass

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

7 years agonitrestful: generate code for async restful methods
Alexis Laferrière [Fri, 14 Oct 2016 18:41:46 +0000 (14:41 -0400)]
nitrestful: generate code for async restful methods

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

7 years agonitrestful: detect the async keyword
Alexis Laferrière [Fri, 14 Oct 2016 13:29:38 +0000 (09:29 -0400)]
nitrestful: detect the async keyword

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

7 years agonitcorn: intro RestfulTask
Alexis Laferrière [Fri, 14 Oct 2016 13:29:10 +0000 (09:29 -0400)]
nitcorn: intro RestfulTask

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

7 years agonitrestful: intercept at `prepare_respond_and_close` instead
Alexis Laferrière [Fri, 14 Oct 2016 17:50:40 +0000 (13:50 -0400)]
nitrestful: intercept at `prepare_respond_and_close` instead

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

7 years agonitrestful: fallback on other restful services if one fails type check
Alexis Laferrière [Fri, 14 Oct 2016 17:49:25 +0000 (13:49 -0400)]
nitrestful: fallback on other restful services if one fails type check

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

7 years agolibevent: intro services for threads and fork
Alexis Laferrière [Sun, 16 Oct 2016 14:06:29 +0000 (10:06 -0400)]
libevent: intro services for threads and fork

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

7 years agopthreads: intro `ThreadPool::join_all`
Alexis Laferrière [Fri, 3 Feb 2017 19:37:22 +0000 (14:37 -0500)]
pthreads: intro `ThreadPool::join_all`

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

7 years agopthreads: allow to set `ThreadPool::nb_thread` before first execute
Alexis Laferrière [Fri, 3 Feb 2017 19:37:01 +0000 (14:37 -0500)]
pthreads: allow to set `ThreadPool::nb_thread` before first execute

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

7 years agopthreads: `ThreadPool` accept any `Task`
Alexis Laferrière [Fri, 3 Feb 2017 19:35:56 +0000 (14:35 -0500)]
pthreads: `ThreadPool` accept any `Task`

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

7 years agotests: add tests for nitunit before and after module
Alexandre Terrasa [Fri, 3 Feb 2017 06:56:06 +0000 (01:56 -0500)]
tests: add tests for nitunit before and after module

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

7 years agolib/test_suite: update Sys class to nitunit fix
Alexandre Terrasa [Fri, 3 Feb 2017 06:55:34 +0000 (01:55 -0500)]
lib/test_suite: update Sys class to nitunit fix

We need the private method so we can compile the test case with intrude.

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

7 years agotesting: compile before and after methods
Alexandre Terrasa [Fri, 3 Feb 2017 06:54:28 +0000 (01:54 -0500)]
testing: compile before and after methods

Tests case will fail if the before method failed.

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

7 years agotesting: fix `before_module` and `after_module` method recognition
Alexandre Terrasa [Fri, 3 Feb 2017 06:52:33 +0000 (01:52 -0500)]
testing: fix `before_module` and `after_module` method recognition

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

7 years agotesting: extract `fail` method to make a test case fail without running it
Alexandre Terrasa [Fri, 3 Feb 2017 06:51:55 +0000 (01:51 -0500)]
testing: extract `fail` method to make a test case fail without running it

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

7 years agocore: Float::sleep to handle interruptions
Alexis Laferrière [Thu, 2 Feb 2017 19:48:21 +0000 (14:48 -0500)]
core: Float::sleep to handle interruptions

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

7 years agojson: support reading plain JSON map when the static type is known
Alexis Laferrière [Sat, 15 Oct 2016 02:38:55 +0000 (22:38 -0400)]
json: support reading plain JSON map when the static type is known

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

7 years agotests: update metrics because the new fictive bottom module
Jean Privat [Wed, 1 Feb 2017 15:29:55 +0000 (10:29 -0500)]
tests: update metrics because the new fictive bottom module

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

7 years agomodelbuilder: drop the fictive bottom module if unneeded
Jean Privat [Wed, 1 Feb 2017 13:42:05 +0000 (08:42 -0500)]
modelbuilder: drop the fictive bottom module if unneeded

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

7 years agomodelbuilder: add `inject_module_subimportation` to inject importation.
Jean Privat [Tue, 31 Jan 2017 19:35:11 +0000 (14:35 -0500)]
modelbuilder: add `inject_module_subimportation` to inject importation.

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

7 years agophase: use a extensible work-list for `run_phases`
Jean Privat [Tue, 31 Jan 2017 19:30:08 +0000 (14:30 -0500)]
phase: use a extensible work-list for `run_phases`

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

7 years agoloader: only apply conditional importation on strict submodules
Jean Privat [Tue, 31 Jan 2017 19:25:48 +0000 (14:25 -0500)]
loader: only apply conditional importation on strict submodules

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

7 years agomodelbuilder: always create a main fictive module
Jean Privat [Tue, 31 Jan 2017 19:24:58 +0000 (14:24 -0500)]
modelbuilder: always create a main fictive module

This simplify the logic and the number of assumptions.

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

7 years agonitc: first_real_mmodule is now explicitly set.
Jean Privat [Tue, 31 Jan 2017 18:54:26 +0000 (13:54 -0500)]
nitc: first_real_mmodule is now explicitly set.

This solve the issue where `nitc foo.nit -m subfoo.nit` program
is named `subfoo` instead of `foo`.

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

7 years agorealtime: don't use custom functions on Sierra
Alexis Laferrière [Thu, 2 Feb 2017 16:23:53 +0000 (11:23 -0500)]
realtime: don't use custom functions on Sierra

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

7 years agoMerge: nitweb: close quicksearch box when clicking outside of it
Jean Privat [Wed, 18 Jan 2017 20:23:56 +0000 (15:23 -0500)]
Merge: nitweb: close quicksearch box when clicking outside of it

* Add some crappyjs(TM) to autoclose the search box when the user click somewhere else.
* Also autoclose the box when the user click on a link from the list (unwanted js sideeffects are sometimes wanted)

Checks one more box from #2178

Demo: http://nitweb.moz-code.org

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

Pull-Request: #2354

7 years agoMerge: nitweb: auto link entitites found in `span code`
Jean Privat [Wed, 18 Jan 2017 20:23:54 +0000 (15:23 -0500)]
Merge: nitweb: auto link entitites found in `span code`

This PR introduces a stub feature for nitweb: autolinking entities from `span` code.

Each time nitweb renders a Markdown comment it evaluates the content of each inline `code` tag and tries to match it with the model index. If the content of the `code` tag matches a package, module, class or property, the `code` content is wrapped in a link to that entity.

Examples:

* `Object`: will be rendered as `<a href='/doc/core::Object'>Object</a>`
* `nullable Object`: will be rendered as `<a href='/doc/core::Object'>nullable Object</a>`
* `is_same_instance`: will be rendered as `<a href='/doc/core::Object::is_same_instance'>is_same_instance</a>`.

The name matching algorithm is the same as the one used to resolve short links like `[Object]` or complex directives like `[graph: core]`.

Demo: http://nitweb.moz-code.org

The documentation from the `core` package benefits from the new feature: http://nitweb.moz-code.org/doc/core

Pull-Request: #2353

7 years agoMerge: Revamp the C string to Nit string services to put forward the safest alternative
Jean Privat [Wed, 18 Jan 2017 13:42:19 +0000 (08:42 -0500)]
Merge: Revamp the C string to Nit string services to put forward the safest alternative

There are now three services to convert a `CString` to a `String`:

* `CString::to_s` and `to_s_with_length(byte_length)` copies data into the GC memory and clean the UTF-8 characters. The difference is that `to_s` search for the first null byte to find the length of the string. These services are the safest and recommended for use with the FFI. They replace the old `to_s_with_copy` and `to_s_with_copy_and_length`.

* `CString::to_s_unsafe(byte_length, char_length, copy, clean)` is the unsafe alternative. It can optimize conversion of a string that has already been cleaned, is already in the GC memory or of which the number of characters has already been counted. This service unifies (and replace) the old `to_s`, `to_s_with_length`, `to_s_full` and `to_s_unsafe`.

Also fix `from_percent_encoding` that did not clean its output, same for the binary deserialization of single characters, and `environ` which now copies the C string into GC memory.

Update a test result as there is now one more string (the copy by `environ`) and a call to `String::length` to cut on the calls to `CString::utf8_length`.

This PR applies #2057 and it is based on #2347. That a look at the commit "core: revamp `CString::to_s` services" first.

Edit: The full doc and signature of `to_s_unsafe` for ease of reading:

# Get a `String` from the data at `self` (with unsafe options)
#
# The default behavior is the safest and equivalent to `to_s`.
#
# Options:
#
# * Set `byte_length` to the number of bytes to use as data.
#   Otherwise, this method searches for a terminating null byte.
#
# * Set `char_length` to the number of Unicode character in the string.
#   Otherwise, the data is read to count the characters.
#   Ignored if `clean == true`.
#
# * If `copy == true`, the default, copies the data at `self` in the
#   Nit GC allocated memory. Otherwise, the return may still point to
#   the data at `self`.
#
# * If `clean == true`, the default, the string is cleaned of invalid UTF-8
#   characters. If cleaning is necessary, the data is copied into Nit GC
#   managed memory, whether or not `copy == true`.
#   Don't clean only when the data has already been verified as valid UTF-8,
#   other library services rely on UTF-8 compliant characters.
fun to_s_unsafe(byte_length, char_length: nullable Int, copy, clean: nullable Bool): String

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

7 years agonitweb: link entities from Markdown code span
Alexandre Terrasa [Sun, 11 Dec 2016 10:27:42 +0000 (05:27 -0500)]
nitweb: link entities from Markdown code span

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

7 years agonitweb: factorize md utilies to MDEmiter instead of DocCommand
Alexandre Terrasa [Sun, 11 Dec 2016 09:28:28 +0000 (04:28 -0500)]
nitweb: factorize md utilies to MDEmiter instead of DocCommand

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

7 years agonitweb: close quick search box when clicking outside
Alexandre Terrasa [Tue, 17 Jan 2017 20:53:46 +0000 (15:53 -0500)]
nitweb: close quick search box when clicking outside

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

7 years agoMerge: Benitlux: Improve the iOS variation and general bug fixes
Jean Privat [Tue, 17 Jan 2017 20:44:00 +0000 (15:44 -0500)]
Merge: Benitlux: Improve the iOS variation and general bug fixes

General improvements to Benitlux:
* Don't suggest to follow current friends.
* Don't allow to post a review when not logged in.
* Forget current login on an invalid token and don't recheck them.
* Extract the manual button for checking in and out to its own module.
* Use more precise classes to offer more variation points for platform adaptations.

Improvements to the look on iOS:
* Rely on the new default behavior of the iOS implementation of *app.nit* to ellipsize long texts.
* Less auto correct and auto capitalizing.
* Use placeholder text to identify text fields.
* Prettier views and windows in general, more alignment, text color, sizes, etc.
* Fix icon when the font is missing.

See the result for yourself!
![Benitlux on iOS](http://xymus.net/pub/ben-ios.png)

Pull-Request: #2352

7 years agobenitlux: move manual checkin feature to its own module
Alexis Laferrière [Mon, 2 Jan 2017 19:28:08 +0000 (14:28 -0500)]
benitlux: move manual checkin feature to its own module

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

7 years agobenitlux: prettier iOS adaptation
Alexis Laferrière [Mon, 26 Sep 2016 17:29:44 +0000 (13:29 -0400)]
benitlux: prettier iOS adaptation

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

7 years agobenitlux: revamp the signup window with more variation points
Alexis Laferrière [Mon, 26 Sep 2016 22:42:06 +0000 (18:42 -0400)]
benitlux: revamp the signup window with more variation points

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

7 years agobenitlux: classify views in simple classes as variation points
Alexis Laferrière [Sun, 25 Sep 2016 23:11:07 +0000 (19:11 -0400)]
benitlux: classify views in simple classes as variation points

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

7 years agobenitlux server: don't suggest current friends
Alexis Laferrière [Sun, 25 Sep 2016 23:14:24 +0000 (19:14 -0400)]
benitlux server: don't suggest current friends

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

7 years agobenitlux: make BeerView labels public attributes so they are variation points
Alexis Laferrière [Sun, 25 Sep 2016 23:13:53 +0000 (19:13 -0400)]
benitlux: make BeerView labels public attributes so they are variation points

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

7 years agobenitlux: refresh home window on receiving an invalid token error
Alexis Laferrière [Sun, 25 Sep 2016 23:12:33 +0000 (19:12 -0400)]
benitlux: refresh home window on receiving an invalid token error

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

7 years agobenitlux: don't endlessly recheck token if its invalid
Alexis Laferrière [Sun, 25 Sep 2016 23:10:18 +0000 (19:10 -0400)]
benitlux: don't endlessly recheck token if its invalid

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

7 years agobenitlux: fix size and alignment of Star & Follow Button
Alexis Laferrière [Sun, 25 Sep 2016 23:09:07 +0000 (19:09 -0400)]
benitlux: fix size and alignment of Star & Follow Button

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

7 years agobenitlux: flatten icon text to path
Alexis Laferrière [Sat, 24 Sep 2016 12:23:24 +0000 (08:23 -0400)]
benitlux: flatten icon text to path

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

7 years agobenitlux: expect that native objects will be freed between log ins and outs
Alexis Laferrière [Fri, 23 Sep 2016 14:59:46 +0000 (10:59 -0400)]
benitlux: expect that native objects will be freed between log ins and outs

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

7 years agobenitlux: disable autocorrect and autocapital.. on user name input text field
Alexis Laferrière [Fri, 23 Sep 2016 02:59:06 +0000 (22:59 -0400)]
benitlux: disable autocorrect and autocapital.. on user name input text field

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

7 years agobenitlux: disable star buttons when not logged in
Alexis Laferrière [Fri, 23 Sep 2016 02:58:36 +0000 (22:58 -0400)]
benitlux: disable star buttons when not logged in

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

7 years agobenitlux: drop the custom ellipsizing
Alexis Laferrière [Fri, 23 Sep 2016 02:27:14 +0000 (22:27 -0400)]
benitlux: drop the custom ellipsizing

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

7 years agoMerge: calculator: bug fix and small tweaks to the iOS adaptation
Jean Privat [Fri, 30 Dec 2016 20:27:40 +0000 (15:27 -0500)]
Merge: calculator: bug fix and small tweaks to the iOS adaptation

Fix a bug where numbers would be limited to a single digit after some operations.

Improve the look of the calculator under iOS.

Pull-Request: #2351

7 years agoMerge: lib/graph: Fix `to_dot`
Jean Privat [Fri, 30 Dec 2016 20:27:32 +0000 (15:27 -0500)]
Merge: lib/graph: Fix `to_dot`

The `Graph::to_dot` function seldom produced bad dot when used on objects with special formatting in their `to_s` method.

This PR changes that by overriding the ID of a node by an Int.
There is still the concern that the new implementation might explode when used on a very large graph, there might be a better way to generate it or to escape the node's ids, but I can't find another one at the moment.

Poke @ablondin, this might interest you

Pull-Request: #2349
Reviewed-by: Alexandre Blondin Massé <alexandre.blondin.masse@gmail.com>

7 years agoMerge: Rename the extern class `NativeString` to `CString`
Jean Privat [Fri, 30 Dec 2016 20:27:19 +0000 (15:27 -0500)]
Merge: Rename the extern class `NativeString` to `CString`

`NativeString` used to be mainly implemented by the engines, but in the last few years it became gradually a normal extern class. As such, its instances are now C strings (`char *`). Most of its methods are extern and implemented in the library instead of the engines. It is also widely used by extern methods implemented in C as `char *`, the type appears 300+ times in the general lib and 67 times in `lib/core/text`.

This PR renames `NativeString` to `CString`. This change makes it clear to beginner programmers that its instances are pointers to C strings and how they are passed to C code. Plus, it fits better next to `CppString`, `JavaString` and `NSString`.

The only remaining engine not using it as a C string is the Java compiler, which implements it as a Java string. This still works and as long as it behaves like a C string there is no problem.

This PR also updates the related doc and attempts to update all indirect references to the new `CString`.

As discussed with @privat and @R4PaSs.

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

7 years agocalculator: improve iOS variation
Alexis Laferrière [Fri, 9 Sep 2016 12:32:10 +0000 (08:32 -0400)]
calculator: improve iOS variation

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

7 years agocalculator: update language in variations doc
Alexis Laferrière [Fri, 9 Sep 2016 14:40:42 +0000 (10:40 -0400)]
calculator: update language in variations doc

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

7 years agocalculator: rename the module `ios_calculator` to `ios`
Alexis Laferrière [Fri, 9 Sep 2016 12:32:49 +0000 (08:32 -0400)]
calculator: rename the module `ios_calculator` to `ios`

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

7 years agocalculator: fix numbers limited to a single digit after a clean
Alexis Laferrière [Wed, 14 Sep 2016 19:59:04 +0000 (15:59 -0400)]
calculator: fix numbers limited to a single digit after a clean

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