nit.git
6 years agoMerge: Nitweb: boost response time and some improvements
Jean Privat [Thu, 7 Sep 2017 14:48:58 +0000 (10:48 -0400)]
Merge: Nitweb: boost response time and some improvements

The main objective of this PR is to shorten the frontend response time.
The major culprit was that the full documentation was serialized in each response.
This PR makes nitweb return only the synopsis and lets the frontend ask for the full documentation if needed.

Also uniformizes and cleans tabs for entities:
* Moved data between tabs (such as inheritance data to the inheritance tab)
* Added missing tabs for packages and groups (http://nitweb.moz-code.org/doc/core%3Ecollection%3E/defs)

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

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

6 years agoMerge: json: move up general services, support Byte and more
Jean Privat [Thu, 7 Sep 2017 14:48:56 +0000 (10:48 -0400)]
Merge: json: move up general services, support Byte and more

This PR is a general clean up of the `json` package to prepare the support of two new serialization engines, add small new features and fix some issues in code. It should not change its behavior for existing clients.

* Move up some general deserialization services from `json` to `serialization` in order to make them available to other engines. This includes the class name manipulation services and safety services controlling which types are deserialized, including `class_inheritance_metamodel`.

* Support writing and reading `Byte` as either a plain JSON string or a special object with metadata.

* Support reading `Char` and `Byte` from plain JSON input using simple heuristics.

* Test the deserialization of plain generated JSON and fix a typo in the tests.

* Fix other minor issues in code.

Pull-Request: #2538

6 years agoMerge: gamnit: shadow mapping
Jean Privat [Thu, 7 Sep 2017 14:48:53 +0000 (10:48 -0400)]
Merge: gamnit: shadow mapping

Intro a basic API and the shaders for 3D actors to cast shadows. This feature is off by default, it can be activated by using a sun-like light with: `app.light = new ParallelLight`. This will require additional work to improve the performance, add more kind of lights (point, spotlight, ambient, etc.), support many lights and accept colored lights.

Many values can be tweaked to achieve the best performance tradeoff:

* `ParallelLight` is always centered on the `world_camera` to show shadows only around the player. Its attributes `width, height, depth` are in world coordinates and identify a prism where shadows are computed. Higher values show shadows further away and lower values show shadows in higher resolution.
* `App::shadow_resolution` sets the resolution of the depth texture. Higher is prettier but slower, there's also an upper limit depending on the hardware configuration. It is now hardcoded (but refinable) to 4096x4096 pixels, with is probably too high for some mobiles devices. More experimentation is needed to find a safe default value.
* For softer shadow edges, the shader applies a kind of antialiasing by tapping the depth texture many times for each fragment. It is currently hardcoded to 4 taps per fragment but it could be changed for better performances or smoother edges. I don't know where to expose this value in the API, it could be on the light, the material or even global. It can also be optimized by the hardware.

### Screenshots from Jump 'n' Gun

Looking down at the player's shadow:

![screenshot from 2017-08-29 10-31-48](https://user-images.githubusercontent.com/208057/29829419-62b27cfa-8cad-11e7-9d95-696e594f4490.png)

Complex shadows from a turret and a shield projector:

![screenshot from 2017-08-29 10-35-45](https://user-images.githubusercontent.com/208057/29829415-5f08d5c2-8cad-11e7-87ca-5e4566d2432b.png)

Pull-Request: #2543

6 years agojson: fixme interpreter bug in constructors with return (#2546)
Alexis Laferrière [Thu, 31 Aug 2017 17:23:30 +0000 (13:23 -0400)]
json: fixme interpreter bug in constructors with return (#2546)

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

6 years agoserialization: move StrictHashMap related services
Alexis Laferrière [Thu, 27 Jul 2017 03:30:10 +0000 (23:30 -0400)]
serialization: move StrictHashMap related services

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

6 years agoserialization: move up deser. safety services from `json`
Alexis Laferrière [Wed, 26 Jul 2017 15:01:52 +0000 (11:01 -0400)]
serialization: move up deser. safety services from `json`

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

6 years agoMerge: nitc: loader skip dot (hidden) directory
Jean Privat [Thu, 31 Aug 2017 19:44:15 +0000 (15:44 -0400)]
Merge: nitc: loader skip dot (hidden) directory

This will improve the loading time when there is a very
deep .git directory around.

Pull-Request: #2534

6 years agoMerge: gamnit audio: control sound channels and don't crash if there's no sound card
Jean Privat [Thu, 31 Aug 2017 19:44:13 +0000 (15:44 -0400)]
Merge: gamnit audio: control sound channels and don't crash if there's no sound card

Desktop clients can now control playing sounds with the new services from SDL2 mixer. The equivalent was already implemented for Android but not GNU/Linux. The new services still need to be fully exposed in the `app::audio` API.

This PR also removes the requirement to have a working sound card to launch a gamnit game.

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

6 years agoMerge: json: remove the old nitcc parser
Jean Privat [Thu, 31 Aug 2017 19:44:12 +0000 (15:44 -0400)]
Merge: json: remove the old nitcc parser

Improve performances of the `json` package by removing the old nitcc parser to use only the custom string parser. It is faster at runtime and the nitcc parser classes were included with the JSON serialization services, slowing down compilation time even when not used.

The nitcc parser was still used only by a few clients, the only differences for the clients should be the error message, conflicts on the `Location` class, and improved performances.

It may be hard to see in the diff but the only differences in the `json` package are: the removal of the nitcc parser, move the string_parser in `static` (they are highly coupled), and make a few services private.

Note that the JSON nitcc grammar is still available in the nitcc project folder.

Warning: Until there's a service like `full_class_name`, deserializing classes with a name conflict is broken. I don't think that the 2-3 cases in the PR deserialize the generated JSON, so it should be OK for now.

Pull-Request: #2540

6 years agoMerge: dom: fix two possible out of bounds string accesses
Jean Privat [Thu, 31 Aug 2017 19:44:11 +0000 (15:44 -0400)]
Merge: dom: fix two possible out of bounds string accesses

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

6 years agoMerge: lib/markdown: fix crash of the parser when parsing unfinished refs
Jean Privat [Thu, 31 Aug 2017 19:43:59 +0000 (15:43 -0400)]
Merge: lib/markdown: fix crash of the parser when parsing unfinished refs

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

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

6 years agoMerge: lib/mongodb: fix database_names test
Jean Privat [Thu, 31 Aug 2017 19:43:58 +0000 (15:43 -0400)]
Merge: lib/mongodb: fix database_names test

Pull-Request: #2545

6 years agogamnit: don't crash if there is no sound
Alexis Laferrière [Sat, 29 Jul 2017 11:31:44 +0000 (07:31 -0400)]
gamnit: don't crash if there is no sound

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

6 years agolinux::audio: extract `play_channel`
Alexis Laferrière [Thu, 13 Jul 2017 01:44:58 +0000 (21:44 -0400)]
linux::audio: extract `play_channel`

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

6 years agosdl2: add more `mixer` services
Alexis Laferrière [Wed, 12 Jul 2017 13:16:39 +0000 (09:16 -0400)]
sdl2: add more `mixer` services

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

6 years agoserialization: move up type name manipulation services out of `json`
Alexis Laferrière [Wed, 26 Jul 2017 12:05:02 +0000 (08:05 -0400)]
serialization: move up type name manipulation services out of `json`

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

6 years agojson: test deser. from plain JSON and fix typo
Alexis Laferrière [Thu, 27 Jul 2017 16:03:58 +0000 (12:03 -0400)]
json: test deser. from plain JSON and fix typo

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

6 years agogamnit: intro basic shadow mapping
Alexis Laferrière [Sat, 19 Aug 2017 18:57:19 +0000 (14:57 -0400)]
gamnit: intro basic shadow mapping

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

6 years agotests: udate more tests testing or depending on the JSON parser
Alexis Laferrière [Thu, 31 Aug 2017 13:52:15 +0000 (09:52 -0400)]
tests: udate more tests testing or depending on the JSON parser

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

6 years agomodel & neo: fix ambiguity in the use of Location
Alexis Laferrière [Tue, 22 Aug 2017 22:52:02 +0000 (18:52 -0400)]
model & neo: fix ambiguity in the use of Location

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

6 years agoneo_doxygen: fix a few "type repetition" warnings
Alexis Laferrière [Tue, 22 Aug 2017 17:50:18 +0000 (13:50 -0400)]
neo_doxygen: fix a few "type repetition" warnings

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

6 years agoneo_doxygen: remove ambiguity in the use of Location
Alexis Laferrière [Tue, 22 Aug 2017 17:49:08 +0000 (13:49 -0400)]
neo_doxygen: remove ambiguity in the use of Location

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

6 years agojson: update expected error in unit test
Alexis Laferrière [Tue, 22 Aug 2017 19:50:34 +0000 (15:50 -0400)]
json: update expected error in unit test

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

6 years agojson: remove the old nitcc parser
Alexis Laferrière [Thu, 3 Aug 2017 16:46:30 +0000 (12:46 -0400)]
json: remove the old nitcc parser

And move the content of `string_parser` to `static` because of high
coupling.

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

6 years agolib/mongodb: fix database_names test
Jean Privat [Wed, 30 Aug 2017 18:38:42 +0000 (14:38 -0400)]
lib/mongodb: fix database_names test

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

6 years agolib/markdown: fix crash of the parser when parsing unfinished refs
Alexandre Terrasa [Tue, 29 Aug 2017 17:02:05 +0000 (13:02 -0400)]
lib/markdown: fix crash of the parser when parsing unfinished refs

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

6 years agogamnit: add camera parameter to `draw` method
Alexis Laferrière [Fri, 18 Aug 2017 17:49:35 +0000 (13:49 -0400)]
gamnit: add camera parameter to `draw` method

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

6 years agogamnit: intro UniformInt
Alexis Laferrière [Mon, 21 Aug 2017 15:25:58 +0000 (11:25 -0400)]
gamnit: intro UniformInt

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

6 years agogamnit: cull back faces
Alexis Laferrière [Mon, 21 Aug 2017 13:22:09 +0000 (09:22 -0400)]
gamnit: cull back faces

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

6 years agogamnit: fix 3D objects in dynamic resolution
Alexis Laferrière [Fri, 18 Aug 2017 14:31:27 +0000 (10:31 -0400)]
gamnit: fix 3D objects in dynamic resolution

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

6 years agodom: fix two possible out of bounds string accesses
Alexis Laferrière [Mon, 17 Jul 2017 02:43:49 +0000 (22:43 -0400)]
dom: fix two possible out of bounds string accesses

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

6 years agogit: restrict -diff attributes to specific files
Alexis Laferrière [Tue, 29 Aug 2017 12:00:25 +0000 (08:00 -0400)]
git: restrict -diff attributes to specific files

Fix an issue where all `parser.nit` files didn't show a diff.
It wrongly caught lib/dom/parser.nit.

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

6 years agonitc: serialization phase use the qualified class name in code gen
Alexis Laferrière [Tue, 22 Aug 2017 23:20:25 +0000 (19:20 -0400)]
nitc: serialization phase use the qualified class name in code gen

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

6 years agogamnit: print current config and list extensions
Alexis Laferrière [Wed, 16 Aug 2017 02:29:22 +0000 (22:29 -0400)]
gamnit: print current config and list extensions

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

6 years agoglesv2 & gamnit: fix typos and minor issues
Alexis Laferrière [Sat, 19 Aug 2017 20:33:16 +0000 (16:33 -0400)]
glesv2 & gamnit: fix typos and minor issues

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

6 years agoglesv2: intro glGetString
Alexis Laferrière [Wed, 16 Aug 2017 02:28:02 +0000 (22:28 -0400)]
glesv2: intro glGetString

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

6 years agonitdoc: set icons for each kind of cards
Alexandre Terrasa [Sat, 17 Jun 2017 22:27:01 +0000 (18:27 -0400)]
nitdoc: set icons for each kind of cards

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

6 years agonitweb: display defs tab for mpackages and mgroups
Alexandre Terrasa [Sat, 17 Jun 2017 21:45:38 +0000 (17:45 -0400)]
nitweb: display defs tab for mpackages and mgroups

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

6 years agonitdoc: api returns defs for packages and groups
Alexandre Terrasa [Sat, 17 Jun 2017 21:45:01 +0000 (17:45 -0400)]
nitdoc: api returns defs for packages and groups

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

6 years agonitweb: do not show inheritance data in doc tab
Alexandre Terrasa [Sat, 17 Jun 2017 20:51:13 +0000 (16:51 -0400)]
nitweb: do not show inheritance data in doc tab

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

6 years agonitweb: show parents and children in inheritance tab
Alexandre Terrasa [Sat, 17 Jun 2017 20:49:21 +0000 (16:49 -0400)]
nitweb: show parents and children in inheritance tab

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

6 years agonitweb: serialize POSetElement to JSON
Alexandre Terrasa [Sat, 17 Jun 2017 20:48:41 +0000 (16:48 -0400)]
nitweb: serialize POSetElement to JSON

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

6 years agonitweb: remove doc tab from entity card
Alexandre Terrasa [Sat, 17 Jun 2017 20:23:39 +0000 (16:23 -0400)]
nitweb: remove doc tab from entity card

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

6 years agonitweb: do not return full html doc in entity json
Alexandre Terrasa [Sat, 17 Jun 2017 20:23:11 +0000 (16:23 -0400)]
nitweb: do not return full html doc in entity json

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

6 years agonitweb: frontend load full mdoc
Alexandre Terrasa [Sat, 17 Jun 2017 20:10:15 +0000 (16:10 -0400)]
nitweb: frontend load full mdoc

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

6 years agonitweb: api serves full mdoc
Alexandre Terrasa [Sat, 17 Jun 2017 20:04:58 +0000 (16:04 -0400)]
nitweb: api serves full mdoc

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

6 years agojson: deser. chars serialized as strings and bytes as ints
Alexis Laferrière [Thu, 27 Jul 2017 16:05:13 +0000 (12:05 -0400)]
json: deser. chars serialized as strings and bytes as ints

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

6 years agojson: support `Byte` in a similar way to `Char`
Alexis Laferrière [Wed, 26 Jul 2017 12:21:34 +0000 (08:21 -0400)]
json: support `Byte` in a similar way to `Char`

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

6 years agoserialization: fix typo and warning
Alexis Laferrière [Tue, 25 Jul 2017 15:27:12 +0000 (11:27 -0400)]
serialization: fix typo and warning

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

6 years agojson: avoid repeating if condition
Alexis Laferrière [Thu, 3 Aug 2017 16:46:42 +0000 (12:46 -0400)]
json: avoid repeating if condition

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

6 years agojson: don't reserve an id when not using it
Alexis Laferrière [Tue, 25 Jul 2017 15:26:50 +0000 (11:26 -0400)]
json: don't reserve an id when not using it

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

6 years agonitc: loader skip dot (hidden) directory
Jean Privat [Thu, 3 Aug 2017 13:48:23 +0000 (09:48 -0400)]
nitc: loader skip dot (hidden) directory

This will improve the loading time when there is a very
deep .git directory around.

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

6 years agoMerge: Nitsmell : Adding new code smells and print console updated
Jean Privat [Wed, 2 Aug 2017 18:17:26 +0000 (14:17 -0400)]
Merge: Nitsmell : Adding new code smells and print console updated

Add :
- New "no abstract implementation" code smell
- Toolcontext option to print one by one a detected codesmell
Update :
- Print console improve
- Feature envy codesmell prepose a move help

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

6 years agoMerge: serialization: safe formal types, fix warnings in generated code and more
Jean Privat [Wed, 2 Aug 2017 18:17:06 +0000 (14:17 -0400)]
Merge: serialization: safe formal types, fix warnings in generated code and more

* Use `GetName` to better restrict the accepted static type for attributes with formal types. This should complete the protection against the injection of unexpected types through deserialization (reported by @ppepos).
* Update `nitserial` to intrude import modules with private serializable classes, instead of skipping them. Serializing private classes from the lib should probably be avoided, but at least now we support them and we can see them.
* Fix the deserialization of maps from JSON with metadata and cycles. A difference in the deserialization order could cause a reference to be read before the referenced object. This issue may still be caused by versionning, so a foolproof solution should probably be added to the JSON deserializer.
* Fix a warning in generated code, it was generated for each `serialize` class (quite a lot). It caused 25 warnings just in lib/github/api.nit.
* Implement serialization for the private classes of `core::queue` and don't crash on deserialization errors in `a_star`.

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

6 years agoNitsmell : Adding new code smells and print console updated
Florian Deljarry [Fri, 23 Jun 2017 15:17:24 +0000 (11:17 -0400)]
Nitsmell : Adding new code smells and print console updated

Add :
- New "no abstract implementation" code smell
- Toolcontext option to print one by one a detected codesmell
Update :
- Print console improve
- Feature envy codesmell prepose a move help

Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>

6 years agoMerge: gamnit: misc fixes
Jean Privat [Wed, 2 Aug 2017 13:30:28 +0000 (09:30 -0400)]
Merge: gamnit: misc fixes

Fix various bugs and issues related to gamnit :

* Expose the previously private class `SpriteSet` for clients to access `time` and set `time_mod` (as intended).
* Fix two bugs with animations: a div by zero in the shader that hid non-animated sprites on Android (a div by zero never crashes, but the return value is unspecified in OpenGL ES 2.0), and an array out of bounds error when an animation has a single frame.
* Cache `GamnitDisplay::aspect_ratio` as it appears to be a performance bottleneck.
* Fix the virtual gamepad not being interactive in Asteronits.
* `UICamera::camera_to_ui` returns a `Point3d` that can be used directly as a `Sprite::center`.

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

6 years agoasteronits: fix virtual gamepad
Alexis Laferrière [Tue, 18 Jul 2017 01:35:48 +0000 (21:35 -0400)]
asteronits: fix virtual gamepad

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

6 years agogamnit: don't remap sprites removed from a set after their modification
Alexis Laferrière [Thu, 20 Jul 2017 18:44:22 +0000 (14:44 -0400)]
gamnit: don't remap sprites removed from a set after their modification

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

6 years agogamnit: fix div by zero when there is no animation
Alexis Laferrière [Mon, 17 Jul 2017 18:06:56 +0000 (14:06 -0400)]
gamnit: fix div by zero when there is no animation

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

6 years agogamnit: fix animations with a single frame
Alexis Laferrière [Fri, 14 Jul 2017 16:21:17 +0000 (12:21 -0400)]
gamnit: fix animations with a single frame

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

6 years agogamnit: make `SpriteSet` public so clients can use its services
Alexis Laferrière [Sun, 9 Jul 2017 20:26:36 +0000 (16:26 -0400)]
gamnit: make `SpriteSet` public so clients can use its services

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

6 years agogamnit: `UICamera::camera_to_ui` returns a 3D point
Alexis Laferrière [Sun, 9 Jul 2017 20:26:04 +0000 (16:26 -0400)]
gamnit: `UICamera::camera_to_ui` returns a 3D point

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

6 years agogamnit: cache `GamnitDisplay::aspect_ratio`
Alexis Laferrière [Fri, 7 Jul 2017 20:23:34 +0000 (16:23 -0400)]
gamnit: cache `GamnitDisplay::aspect_ratio`

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

6 years agolib: misc typos
Alexis Laferrière [Mon, 10 Jul 2017 17:56:04 +0000 (13:56 -0400)]
lib: misc typos

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

6 years agoa_star: don't crash on deserialization errors and limit static types
Alexis Laferrière [Sat, 22 Jul 2017 01:08:10 +0000 (21:08 -0400)]
a_star: don't crash on deserialization errors and limit static types

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

6 years agoserialization: implement serialization for classes of `core::queue`
Alexis Laferrière [Sat, 22 Jul 2017 01:19:04 +0000 (21:19 -0400)]
serialization: implement serialization for classes of `core::queue`

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

6 years agotests: add formal types to serialization tests
Alexis Laferrière [Sat, 22 Jul 2017 12:39:57 +0000 (08:39 -0400)]
tests: add formal types to serialization tests

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

6 years agofrontend: don't deserialization code with warnings
Alexis Laferrière [Sat, 22 Jul 2017 02:22:06 +0000 (22:22 -0400)]
frontend: don't deserialization code with warnings

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

6 years agofrontend: don't mention JSON in general deserialization error
Alexis Laferrière [Sat, 22 Jul 2017 12:57:00 +0000 (08:57 -0400)]
frontend: don't mention JSON in general deserialization error

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

6 years agofrontend: safer deserialization of parameter and virtual types
Alexis Laferrière [Sat, 22 Jul 2017 01:26:15 +0000 (21:26 -0400)]
frontend: safer deserialization of parameter and virtual types

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

6 years agojson: standardize error messages
Alexis Laferrière [Sat, 22 Jul 2017 20:07:43 +0000 (16:07 -0400)]
json: standardize error messages

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

6 years agojson: deserialize Maps keys first, in the same order as they are written
Alexis Laferrière [Mon, 24 Jul 2017 14:35:27 +0000 (10:35 -0400)]
json: deserialize Maps keys first, in the same order as they are written

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

6 years agojson: use GetName to restrict deserialized formal types
Alexis Laferrière [Sat, 22 Jul 2017 01:18:20 +0000 (21:18 -0400)]
json: use GetName to restrict deserialized formal types

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

6 years agoserialization: intro `AttributeMissingError`
Alexis Laferrière [Mon, 24 Jul 2017 14:07:56 +0000 (10:07 -0400)]
serialization: intro `AttributeMissingError`

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

6 years agoserialization: update some doc
Alexis Laferrière [Sat, 22 Jul 2017 12:47:49 +0000 (08:47 -0400)]
serialization: update some doc

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

6 years agonitserial: intrude import modules when needed
Alexis Laferrière [Sat, 22 Jul 2017 01:23:07 +0000 (21:23 -0400)]
nitserial: intrude import modules when needed

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

6 years agogen_nit: accept complete import declarations
Alexis Laferrière [Sat, 22 Jul 2017 01:21:58 +0000 (21:21 -0400)]
gen_nit: accept complete import declarations

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

6 years agoMerge: typing: new warning `useless-truism` to catch trainees.
Jean Privat [Tue, 18 Jul 2017 12:38:12 +0000 (08:38 -0400)]
Merge: typing: new warning `useless-truism` to catch trainees.

Warning on `if a == true then` constructions.

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

6 years agoMerge: gamnit: scale text, add custom characters and create links with `BMFont`
Jean Privat [Tue, 18 Jul 2017 12:38:09 +0000 (08:38 -0400)]
Merge: gamnit: scale text, add custom characters and create links with `BMFont`

This PR adds more customization options when drawing text using `BMFont`:

* Change the size of the text with a simple attribute `TextSprites::scale`.
* Insert artificial chars to a `BMFont` using the more permissive `BMFontChar`. This way, one can set custom textures for a letter, an emojis or any character from the private use areas.
* Add "links" to the text using Markdown-like syntax (`[my link]` or `[pretty name](internal name)`). Note that the links are not clickable by themselves. However, the client code can access the sprites representing the link to change their style or to get their position. This will work well with a rumored future feature making sprites clickable...

Notice the colored links and the smaller text box in the following screenshot of `fonts_showcase`:
![screenshot from 2017-07-13 22-09-20](https://user-images.githubusercontent.com/208057/28196740-8f8630b6-6820-11e7-8915-1df02b4edee5.png)

---

Once again, these new features are not implemented for `TileSetFont`. I'm considering keeping the API of `TileSetFont` but replacing its implementation by a `BMFont` for it to gets all the new shiny features.

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

6 years agogamnit: add new features to the fonts_showcase example
Alexis Laferrière [Fri, 14 Jul 2017 03:03:07 +0000 (23:03 -0400)]
gamnit: add new features to the fonts_showcase example

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

6 years agogamnit: add markdown-like links to `TextSprites` with `BMFont`
Alexis Laferrière [Wed, 12 Jul 2017 13:15:32 +0000 (09:15 -0400)]
gamnit: add markdown-like links to `TextSprites` with `BMFont`

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

6 years agolib&contrib: remove some useless truisms.
Jean Privat [Wed, 28 Jun 2017 19:14:31 +0000 (15:14 -0400)]
lib&contrib: remove some useless truisms.

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

6 years agoMerge: model: group parameter types in `MSignature::to_s`
Jean Privat [Mon, 17 Jul 2017 13:53:32 +0000 (09:53 -0400)]
Merge: model: group parameter types in `MSignature::to_s`

Modify `MSignature::to_s` to make its output a shorter valid Nit signature. This helps readability and shortens error messages allowing them to fit more easily on a single line or within a text editor.

Example program:
~~~nit
import geometry
var b = new Box3d[Float] # <- error
~~~

Previous error message:
~~~
Error: expected 6 argument(s) for `init(left: Float, right: Float, top: Float, bottom: Float, front: Float, back: Float)`; got 0. See introduction at `core::Object::init`.
~~~

New error message:
~~~
Error: expected 6 argument(s) for `init(left, right, top, bottom, front, back: Float)`; got 0. See introduction at `core::Object::init`.
~~~

Pull-Request: #2529

6 years agoMerge: quadtree: use an array, fix warnings and standardize the doc
Jean Privat [Mon, 17 Jul 2017 13:53:31 +0000 (09:53 -0400)]
Merge: quadtree: use an array, fix warnings and standardize the doc

Replace the 4 attributes by an array of all the children. This new structure lightens the code and allows to fix 65 `method call on a nullable receiver` warnings. As this is already a significant refactor, I avoided modifying further the implementations to avoid breaking things.

Pull-Request: #2528

6 years agoMerge: gamnit: control drawing order
Jean Privat [Mon, 17 Jul 2017 13:53:30 +0000 (09:53 -0400)]
Merge: gamnit: control drawing order

When two sprites are overlapped, a non-opaque pixel drawn before the sprite behind it may be blended with the wrong color. The only solution is to control the draw order to ensure that sprites in the back are drawn first. However, this is hard to automate when grouping sprites in buffers to optimize the drawing of a very large number of sprites (as gamnit does). It requires to break off groups in layers and this may be very costly if the sprites move on the Z axis.

The solution it to let the programmer choose a draw order only when needed. This works pretty well in 2D games where some objects stay on the same relative depth layer.

> Example artifacts on the left, and the fixed result (with a `sprite.draw_order = 1`) on the right:
>
> ![bug1](https://user-images.githubusercontent.com/208057/28196073-3e0ec6fc-681c-11e7-98d0-019e25a7f9c3.png) ![fixed1](https://user-images.githubusercontent.com/208057/28196072-3dfe075e-681c-11e7-9f4d-8d08a45b9661.png)

This PR introduces the attribute `Sprite::draw_order` that can be set to a higher value (default at 0) for the sprite to be drawn later. In general, sprites with a non-opaque `texture` and sprites closer to the camera should have a higher value to be drawn last.

Sprites sharing a `draw_order` are drawn in the same pass. The sprite to sprite draw order is undefined and may change when adding and removing sprites, or changing their attributes. A future improvement could sort sprites in the same group automatically if it becomes an issue.

Note that changing the `draw_order` may have a negative performance impact if there are many different `draw_order` values across many sprites. This may break the grouping optimization by creating too many small groups.

---

I plan on adding the draw order to `gamnit::depth` actors too. This will be useful for games than mix 2D with 3D. However, I would have to apply a different strategy for pure 3D games, implementing two main passes, one for opaque objects and one for non-opaque objects.

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

6 years agoMerge: gtksourceview: Add the missing `kwnull` context
Jean Privat [Mon, 17 Jul 2017 13:53:28 +0000 (09:53 -0400)]
Merge: gtksourceview: Add the missing `kwnull` context

Renderings for `test_syntax.nit`:
* [Classic](https://github.com/nitlang/nit/files/1148477/gtksourceview-classic.pdf)
* [Kate](https://github.com/nitlang/nit/files/1148476/gtksourceview-kate.pdf)
* [Solarized Clear](https://github.com/nitlang/nit/files/1148474/gtksourceview-solarized-clear.pdf)
* [Tango](https://github.com/nitlang/nit/files/1148475/gtksourceview-tango.pdf)

For comparison, see #2515.

![WHOOPS!!](https://user-images.githubusercontent.com/6044484/28213673-23e5b296-6875-11e7-8a2b-494652afe064.png "WHOOPS!!")

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2525

6 years agoMerge: vim plugin: list introduction and redefinition locations to goto files
Jean Privat [Mon, 17 Jul 2017 13:53:27 +0000 (09:53 -0400)]
Merge: vim plugin: list introduction and redefinition locations to goto files

This PR improves the functions `:Nitdoc` and `:NitGitGrep` for easier navigation in large Nit projects.

### :Nitdoc

When calling `:Nitdoc write_and_make`, or simply `:Nitdoc` with the cursor above the word `write_and_make`, or even using the recommended shortcut Ctrl-D, the preview window now lists the relevant files after the doc of the two different methods accessible from `nitc`:

~~~markdown
# nitc::abstract_compiler$ModelBuilder$write_and_make(compiler: AbstractCompiler)

Simple indirection to `Toolchain::write_and_make`

## Location of introduction and refinements
* src/compiler/abstract_compiler.nit:112,2--119,4
* src/compiler/compiler_serialization.nit:22,2--38,4

# nitc$Toolchain$write_and_make

Write all C files and compile them

## Location of introduction and refinements
* src/compiler/abstract_compiler.nit:154,2--155,31 (1 more)
~~~

The path format is supported by Vim, so you can move the cursor above a path and hit `gF` (goto file) to open the file at the first line. There are alternatives to `gF`, I personally mapped `Ctrl-W gF` to `Ctrl-A` to open the file in a new tab.

### :NitGitGrep

Calling `:NitGitGrep` (or using the recommended Ctrl-G) search for the word under the cursor in Nit files in the local Git repo. This PR changes a few settings are in order to:

* Print line number after the file path, so you can use `gF` here too.
* Show the introduction(s) before the redefs.
* Search for the complete word under the cursor.
* Search only in Nit source files.
* Avoid duplicating results.

When called above `write_and_make` the preview window lists the intros first, then the redefs and then the other references after a blank line:
~~~
src/compiler/abstract_compiler.nit:113: protected fun write_and_make(compiler: AbstractCompiler)
src/compiler/abstract_compiler.nit:155: fun write_and_make is abstract
src/compiler/java_compiler.nit:64: fun write_and_make(compiler: JavaCompiler) do
src/compiler/abstract_compiler.nit:162: redef fun write_and_make
src/compiler/compiler_serialization.nit:22: redef fun write_and_make(compiler)

src/compiler/abstract_compiler.nit:112: # Simple indirection to `Toolchain::write_and_make`
src/compiler/abstract_compiler.nit:118: toolchain.write_and_make
src/compiler/abstract_compiler.nit:578: # Set by `modelbuilder.write_and_make` and permit sub-routines to access the current toolchain if required.
src/compiler/global_compiler.nit:67: write_and_make(compiler)
src/compiler/java_compiler.nit:60: write_and_make(compiler)
src/compiler/separate_compiler.nit:126: write_and_make(compiler)
src/compiler/separate_erasure_compiler.nit:77: write_and_make(compiler)
~~~

Note that searching only for the word itselt, the result doesn't distinguish between the 3 versions of `write_and_make`, including one not imported by `nitc`.

Pull-Request: #2524

6 years agogamnit: make `BMFontChar` more permissive to accept artificial fonts
Alexis Laferrière [Wed, 12 Jul 2017 02:28:13 +0000 (22:28 -0400)]
gamnit: make `BMFontChar` more permissive to accept artificial fonts

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

6 years agomodel: group types in `MSignature::to_s`
Alexis Laferrière [Fri, 14 Jul 2017 00:48:36 +0000 (20:48 -0400)]
model: group types in `MSignature::to_s`

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

6 years agogtksourceview: Add the missing `kwnull` context
Jean-Christophe Beaupré [Fri, 14 Jul 2017 13:07:01 +0000 (09:07 -0400)]
gtksourceview: Add the missing `kwnull` context

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agonitpick & vim: list concerned files in doc
Alexis Laferrière [Sat, 8 Jul 2017 15:53:32 +0000 (11:53 -0400)]
nitpick & vim: list concerned files in doc

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

6 years agovim: improve NitGitGrep
Alexis Laferrière [Sun, 2 Jul 2017 01:50:50 +0000 (21:50 -0400)]
vim: improve NitGitGrep

* Print line number after the file path, so you can use `gF` here too.
* Show the introduction(s) before the redefs.
* Search for the complete word under the cursor.
* Search only in Nit source files.
* Avoid duplicating results.

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

6 years agogeometry: fix warnings in quadtree structures and standardize the doc
Alexis Laferrière [Thu, 18 May 2017 19:52:59 +0000 (12:52 -0700)]
geometry: fix warnings in quadtree structures and standardize the doc

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

6 years agogamnit: intro `TextSprite::scale`
Alexis Laferrière [Wed, 12 Jul 2017 00:42:07 +0000 (20:42 -0400)]
gamnit: intro `TextSprite::scale`

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

6 years agogamnit: intro `Sprite::draw_order`
Alexis Laferrière [Fri, 7 Jul 2017 20:47:16 +0000 (16:47 -0400)]
gamnit: intro `Sprite::draw_order`

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

6 years agomore_collections: intro HashMap4
Alexis Laferrière [Fri, 7 Jul 2017 20:22:35 +0000 (16:22 -0400)]
more_collections: intro HashMap4

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

6 years agoMerge: frontend: run code generation phases only in engines (and nitmetrics)
Jean Privat [Tue, 11 Jul 2017 13:01:32 +0000 (09:01 -0400)]
Merge: frontend: run code generation phases only in engines (and nitmetrics)

Some frontend phases generate Nit code (usually method implementations) that is ignored by some tools, including `nitpick`, `nitserial` and `nitrestful`. When running `nitpick` on WBTW, a serialization heavy project, the code generation part of `serialization_phase` uselessly took ~10% of the work time. This extra time adds up quickly as `nitpick` is invoked each time we save a file in vim.

This PR extracts some code generation phases from the main frontend. Compilers and interpreters must import the code generation phases (`frontend::code_gen`) but most others only need the main frontend (`frontend`). Analysis tools may import the code generation phases ito analyze the generated code, or import only the main frontend phases to analyze only the user code.

In this PR, only two phases have been moved: half of `serialization_phase` which was the most costly in my use case, and `actors_generation_phase` because it was already nicely decoupled (well done @BlackMinou!). Others phases could be divided and moved to the code generation frontend if they happen to be a performance bottleneck: `i18n_phase`, `parallelization_phase` and maybe `deriving`.

Note that there is no implementation change to the serialization phase, I simply split the module in two.

Pull-Request: #2523

6 years agoMerge: poset: add lookup services in Map to search using keys in hierarchies.
Jean Privat [Tue, 11 Jul 2017 12:59:58 +0000 (08:59 -0400)]
Merge: poset: add lookup services in Map to search using keys in hierarchies.

3 main methods:

* `Map::lookup_all_values` collect all values of the greaters of an element
* `Map::lookup_values` collect only the values of the most specific greaters of an element
* `MultiHashMap::lookup_joined_values` collect and join the values of the most specific greaters of an element

Since many models entities in nitc are in some poset, these services could be used
to add and retrieve metadata while automatically taking in account inheritance or importation.

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

Pull-Request: #2500

6 years agoMerge: gmp: Introduce Long and Ratio
Jean Privat [Tue, 11 Jul 2017 12:59:05 +0000 (08:59 -0400)]
Merge: gmp: Introduce Long and Ratio

Signed-off-by: PatrickBlanchette <PatrickBlanchette@users.noreply.github.com>

Pull-Request: #2508
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Blondin Massé <alexandre.blondin.masse@gmail.com>
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

6 years agogmp: Introduce BigInt and Ratio
PatrickBlanchette [Tue, 20 Jun 2017 14:24:08 +0000 (10:24 -0400)]
gmp: Introduce BigInt and Ratio

Signed-off-by: PatrickBlanchette <PatrickBlanchette@users.noreply.github.com>