nit.git
6 years agosrc/doc_commands: merge Article and Comment commands
Alexandre Terrasa [Tue, 29 Aug 2017 23:52:35 +0000 (19:52 -0400)]
src/doc_commands: merge Article and Comment commands

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

6 years agonitweb: use new doc commands parser
Alexandre Terrasa [Tue, 29 Aug 2017 23:32:12 +0000 (19:32 -0400)]
nitweb: use new doc commands parser

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

6 years agonitdoc: use new doc commands parser
Alexandre Terrasa [Tue, 29 Aug 2017 23:31:59 +0000 (19:31 -0400)]
nitdoc: use new doc commands parser

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

6 years agonitdoc: remove warnings from doc_readme
Alexandre Terrasa [Tue, 29 Aug 2017 22:27:23 +0000 (18:27 -0400)]
nitdoc: remove warnings from doc_readme

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

6 years agonitx: update to doc commands parser
Alexandre Terrasa [Tue, 29 Aug 2017 22:22:29 +0000 (18:22 -0400)]
nitx: update to doc commands parser

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

6 years agosrc/doc_commands: rewrite doc commands parser
Alexandre Terrasa [Tue, 29 Aug 2017 22:22:15 +0000 (18:22 -0400)]
src/doc_commands: rewrite doc commands parser

Also add tests

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

6 years agoMerge: nitunit: use annotations
Jean Privat [Mon, 25 Sep 2017 20:23:07 +0000 (16:23 -0400)]
Merge: nitunit: use annotations

This PR replace the name heuristics used by nitunit by nice and tidy annotations.

Before:

~~~nit
module test_my_test is test_suite

import test_suite

class TestMyTest
    super TestSuite

    redef fun before do # something

    fun test_my_test do
        assert true
    end
end
~~~

After:

~~~nit
module my_test is test

class MyTest
    test

    fun setup is before do # something

    fun my_test is test do
        assert true
    end
end
~~~

Motivations:
* cleaner API / naming policy
* [BDD](https://en.wikipedia.org/wiki/Behavior-driven_development) friendly
* more flexibility as one can define a `after` method in the lib that will only be executed on children module tagged with `test`
* more extensible as one can improve nitunit to support `test(timeout = 150)` or `test(res= "res/test_file.res")`

Used annotations:
* `test` on modules, classes and properties to indicate that nitunit must run this module/class/method
* `before`, `after` on properties from all classes but `Sys` for the before/after each case hooks
* `before_all`, `after_all` on properties from `Sys` for the before/after all cases hooks

This also removes the need of the `lib/test_suite` module.

I also migrated the existing test suites to the new annotations system. Let's see what Jenkins has to say about it.

Should fix #2165

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

6 years agoMerge: gamnit: fluid API, named 3D models, faster nitpick et other fixes
Jean Privat [Mon, 25 Sep 2017 20:23:05 +0000 (16:23 -0400)]
Merge: gamnit: fluid API, named 3D models, faster nitpick et other fixes

General improvements to the gamnit framework and related services:
* Make the APIs of `CustomTexture` and `VirtualGamepad` a bit more fluid.
* More precise computation of `TextSprite::height` and show the result in `font_showcase`.
* Optimize shadow mapping by caching the light MVP matrix.
* Speedup nitpick by silencing some warnings in `glesv2` and fix warnings created by the serialization framework.
* Fix bug on Kabylake GPU reported by @BlackMinou.
* Fix a few other bugs and possible crashes.

Pull-Request: #2551

6 years agogamnit: fix "mismatching precision qualifiers" error on recent Intel GPU
Alexis Laferrière [Mon, 25 Sep 2017 12:38:37 +0000 (08:38 -0400)]
gamnit: fix "mismatching precision qualifiers" error on recent Intel GPU

Reported-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: disable our premultiplication on Android
Alexis Laferrière [Thu, 21 Sep 2017 01:51:54 +0000 (21:51 -0400)]
gamnit: disable our premultiplication on Android

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

6 years agogamnit: compute a more precise `TextSprites::height`
Alexis Laferrière [Fri, 15 Sep 2017 12:17:09 +0000 (08:17 -0400)]
gamnit: compute a more precise `TextSprites::height`

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

6 years agogamnit: fix code duplication in BMFont
Alexis Laferrière [Wed, 20 Sep 2017 16:45:33 +0000 (12:45 -0400)]
gamnit: fix code duplication in BMFont

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

6 years agogamnit: add size info to font_showcase
Alexis Laferrière [Wed, 20 Sep 2017 16:38:56 +0000 (12:38 -0400)]
gamnit: add size info to font_showcase

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

6 years agogamnit: cache the light mvp_matrix
Alexis Laferrière [Mon, 18 Sep 2017 19:21:06 +0000 (15:21 -0400)]
gamnit: cache the light mvp_matrix

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

6 years agoserialization: generate one less warning
Alexis Laferrière [Fri, 15 Sep 2017 15:53:45 +0000 (11:53 -0400)]
serialization: generate one less warning

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

6 years agoglesv2: don't report missing-doc warnings, for a faster nitpick
Alexis Laferrière [Fri, 15 Sep 2017 15:53:18 +0000 (11:53 -0400)]
glesv2: don't report missing-doc warnings, for a faster nitpick

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

6 years agogamnit: fix crash on character missing from font
Alexis Laferrière [Thu, 14 Sep 2017 17:48:19 +0000 (13:48 -0400)]
gamnit: fix crash on character missing from font

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

6 years agogamnit: more precise error when a texture is too large
Alexis Laferrière [Sat, 12 Aug 2017 16:10:36 +0000 (12:10 -0400)]
gamnit: more precise error when a texture is too large

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

6 years agogamnit: `CustomTexture::fill` returns self for easier attribute creation
Alexis Laferrière [Sat, 12 Aug 2017 16:10:27 +0000 (12:10 -0400)]
gamnit: `CustomTexture::fill` returns self for easier attribute creation

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

6 years agogamnit: keep the named sub-object composing an obj object
Alexis Laferrière [Tue, 1 Aug 2017 03:22:57 +0000 (23:22 -0400)]
gamnit: keep the named sub-object composing an obj object

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

6 years agogamnit: virtual gamepad services return the created controls
Alexis Laferrière [Tue, 1 Aug 2017 03:20:17 +0000 (23:20 -0400)]
gamnit: virtual gamepad services return the created controls

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

6 years agoMerge: Intro MessagePack serialization engines
Jean Privat [Fri, 22 Sep 2017 18:30:20 +0000 (14:30 -0400)]
Merge: Intro MessagePack serialization engines

MessagePack is a portable data serialization format. It differs from JSON by its binary format, compressing common types, support for custom types and accepting any object as map key. Here, the primitive Nit types use the shortest available MessagePack format (e.g. an `Int` between -32 and 127 takes a single byte). The custom types are used to declare some metadata and special types (objects, references, `Char`, etc.). The engines can, optionally, benefit from the map keys as any object to compress repeated metadata (class and attribute names).

These engines should replace the current `Binary::serialization` services, which are almost impossible to debug, less compressed than MessagePack and not standard.

The serialization engine supports writing and reading plain (no metadata) MessagePack data, similarly to the JSON engines.

Most clients should use the high-level services:
* Customizable engines to handle errors: `MsgPackSerializer` and `MsgPackDeserializer`.
* Quick services on streams: `Writer::serialize_msgpack` and `Reader::deserialize_msgpack`.
* Quick services on `Bytes` (mostly for testing): `Serializable::serialize_msgpack` and `Bytes::deserialize_msgpack`.

Or, to write engines one can use the low-level services:
* Low-level writing methods: `Writer::write_msgpack_uint64`, `Writer::write_msgpack_bin8`, etc.
* Low-level reading method: `Reader::read_msgpack`.

---

Using it in Jwrapper, the MessagePack format creates smaller files than JSON (at ~50% the size), when using the default options and serializing the metadata of the Java standard library:

* JSON: 14.9 MB
* MessagePack (default): 7.0 MB
* Old binary: 9.8 MB

The file gets shorter in plain MessagePack mode or when caching the metadata strings:
* MessagePack `plain_msgpack=true`: 6.3 MB
* MessagePack `cache_metadata_strings=true`: 3.0 MB

Caching metadata creates much smaller files, however for the size only gzip has a bigger effect.
Further investigations is required to see the impact it has on the speed.

* gzipped MessagePack (default): 0.7 MB
* gzipped MessagePack `cache_metadata_strings=true`: 0.6 MB

---

This PR depends on #2539 as it works on binary data, you can ignore the first 2 commits.

@R4PaSs you may want to look at the commits modifying `Int::to_bytes` and `Bytes::to_i`.

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

6 years agomsgpack: fixme interpreter bug in constructors with return (#2546)
Alexis Laferrière [Tue, 12 Sep 2017 16:21:27 +0000 (12:21 -0400)]
msgpack: fixme interpreter bug in constructors with return (#2546)

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

6 years agojwrapper: don't serialize cached attributes
Alexis Laferrière [Mon, 4 Sep 2017 01:59:15 +0000 (21:59 -0400)]
jwrapper: don't serialize cached attributes

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

6 years agojwrapper: use msgpack
Alexis Laferrière [Sun, 3 Sep 2017 23:37:15 +0000 (19:37 -0400)]
jwrapper: use msgpack

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

6 years agogamnit: use the msgpack engines instead of binary
Alexis Laferrière [Sun, 3 Sep 2017 23:03:18 +0000 (19:03 -0400)]
gamnit: use the msgpack engines instead of binary

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

6 years agomsgpack: test the msgpack serialization engines
Alexis Laferrière [Tue, 25 Jul 2017 20:53:46 +0000 (16:53 -0400)]
msgpack: test the msgpack serialization engines

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

6 years agomsgpack: intro msgpack_to_json tool
Alexis Laferrière [Wed, 26 Jul 2017 14:28:39 +0000 (10:28 -0400)]
msgpack: intro msgpack_to_json tool

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

6 years agomsgpack: intro entrypoint and package doc
Alexis Laferrière [Wed, 26 Jul 2017 02:36:32 +0000 (22:36 -0400)]
msgpack: intro entrypoint and package doc

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

6 years agomsgpack: intro deserialization services
Alexis Laferrière [Wed, 26 Jul 2017 02:36:08 +0000 (22:36 -0400)]
msgpack: intro deserialization services

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

6 years agomsgpack: intro serialization services
Alexis Laferrière [Tue, 25 Jul 2017 20:48:53 +0000 (16:48 -0400)]
msgpack: intro serialization services

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

6 years agomsgpack: intro read services
Alexis Laferrière [Tue, 25 Jul 2017 20:50:30 +0000 (16:50 -0400)]
msgpack: intro read services

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

6 years agomsgpack: intro write services
Alexis Laferrière [Tue, 25 Jul 2017 01:48:30 +0000 (21:48 -0400)]
msgpack: intro write services

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

6 years agocore: `Bytes::to_i` can parse signed ints
Alexis Laferrière [Sat, 2 Sep 2017 22:56:11 +0000 (18:56 -0400)]
core: `Bytes::to_i` can parse signed ints

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

6 years agocore: support signed ints and custom capacity in `Int::to_bytes`
Alexis Laferrière [Tue, 8 Aug 2017 16:23:18 +0000 (12:23 -0400)]
core: support signed ints and custom capacity in `Int::to_bytes`

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

6 years agoMerge: serialization: redef inspect for an output useful to humans
Jean Privat [Mon, 18 Sep 2017 19:00:47 +0000 (15:00 -0400)]
Merge: serialization: redef inspect for an output useful to humans

Intro a new serialization engine to pretty print the attributes of the receiver on calls to `inspect`. The format is designed to be helpful, reproducible and compact.

Note that, asides from direct calls to `inspect`, this will also affect the default behavior of `Serializable::to_s`. And this will not affect all Nit programs, but it will affect all those importing the serialization services, so most larger projects using either `json`, `nitcorn`, `gamnit`, `more_collections`, etc.

Simple immutable data are inspected as they would be written in Nit code:
~~~
assert 123.inspect == "123"
assert 1.5.inspect == "1.5"
assert 0xa1u8.inspect == "0xa1u8"
assert 'c'.inspect == "'c'"
assert "asdf\n".inspect == "\"asdf\\n\""
~~~

Inspections of mutable object show their dynamic type and an id unique to each call to `inspect`. A change from using their `object_id`.

Items of collections are flattened:

~~~
assert [1, 2, 3].inspect == "<Array[Int]#0 [1, 2, 3]>"

var set = new HashSet[Object].from([1, 1.5, "two": Object])
assert set.inspect == """<HashSet[Object]#0 [1, 1.5, "two"]>"""

var map = new Map[Int, String]
map[1] = "one"
map[2] = "two"
assert map.inspect == """<HashMap[Int, String]#0 {1:"one", 2:"two"}>"""
~~~

Inspecting other `Serializable` classes shows the first level attributes only:

~~~
class MyClass
    serialize

    var i: Int
    var o: nullable Object
end

var class_with_null = new MyClass(123)
assert class_with_null.to_s == class_with_null.inspect
assert class_with_null.to_s == "<MyClass#0 i:123, o:null>"

var class_with_other = new MyClass(456, class_with_null)
assert class_with_other.to_s == "<MyClass#0 i:456, o:<MyClass#1>>"

var class_with_cycle = new MyClass(789)
class_with_cycle.o = class_with_cycle
assert class_with_cycle.to_s == "<MyClass#0 i:789, o:<MyClass#0>>"
~~~

Inspections producing over 80 characters are cut short:

~~~
var long_class = new MyClass(123456789, "Some " + "very "*8 + "long string")
assert long_class.to_s == "<MyClass#0 i:123456789, o:\"Some very very very very very very very very long s…>"
~~~

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

6 years agoMerge: core: intro BytesWriter and BytesReader
Jean Privat [Mon, 18 Sep 2017 15:19:50 +0000 (11:19 -0400)]
Merge: core: intro BytesWriter and BytesReader

Intro the classes `BytesReader` and `BytesWriter` to support byte read/writer operations directly on `Bytes` in memory.

The new classes are now super classes to `StringReader` (converting the `String` source to `Bytes` in the constructor) and `StringWriter`(cleaning the UTF-8 string in `to_s` only). The only differences between the string and bytes streams are the behavior of `StringWriter::to_s` and the `String` parameter expected by the constructor of `StringReader`.

`BytesWriter` supports writing any bytes, including composing UTF-8 characters byte by byte, a behavior also useful for `StringWriter`:
~~~
var writer = new BytesWriter

# Write just the character first half
writer.write_byte 0xC2u8
assert writer.to_s == "\\xC2"
assert writer.bytes.to_s == "�"

# Complete the character
writer.write_byte 0xA2u8
assert writer.to_s == "\\xC2\\xA2"
assert writer.bytes.to_s == "¢"
~~~

`BytesReader` also supports reading any bytes, including the bytes composing an UTF-8 character for `StringReader`:

~~~
var reader = new BytesReader(b"a…b")
assert reader.read_char == 'a'
assert reader.read_byte == 0xE2u8 # 1st byte of '…'
assert reader.read_byte == 0x80u8 # 2nd byte of '…'
assert reader.read_char == '�' # Reads the last byte as an invalid char
assert reader.read_all_bytes == b"b"
~~~

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

6 years agoMerge: app.nit: easier root window selection and other misc improvements
Jean Privat [Mon, 18 Sep 2017 15:19:48 +0000 (11:19 -0400)]
Merge: app.nit: easier root window selection and other misc improvements

Intro the hook `root_window` for clients to set the desired root (or home) window. It is much shorter than the previous redef of `on_create`. Plus, in very simple apps, the client can simple redef `Window` instead of subclassing it.

Refactor `data_store` structure, replacing the interface and subclasses by refinements of a single class. It follows more closely the strategy used by the UI API while not changing anything to the `data_store` API. The data store now drops potentially partially deserialized objects to avoid hard to report crash at runtime, this could be improved upon in the future as the current implementation is not ideal.

Otherwise, this PR brings general improvements to the framework influenced by the creation of [paninit.com](http://paninit.com/): revamp the documentation, add unit tests, fix the scientific calculator icon and add an option to report errors in `hightlightcode`.

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

6 years agoserialization: test the inspect serialization engine
Alexis Laferrière [Fri, 8 Sep 2017 00:53:57 +0000 (20:53 -0400)]
serialization: test the inspect serialization engine

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

6 years agoserialization: redef of `inspect` using a new serializer
Alexis Laferrière [Fri, 4 Aug 2017 02:34:02 +0000 (22:34 -0400)]
serialization: redef of `inspect` using a new serializer

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

6 years agocore: Bytes have a minimum capacity of 16 bytes
Alexis Laferrière [Fri, 8 Sep 2017 14:43:32 +0000 (10:43 -0400)]
core: Bytes have a minimum capacity of 16 bytes

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

6 years agocore: optimize Bytes::append_text using redefs in Text subclasses
Alexis Laferrière [Fri, 8 Sep 2017 14:06:31 +0000 (10:06 -0400)]
core: optimize Bytes::append_text using redefs in Text subclasses

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

6 years agocore: protect access to _items in empty strings
Alexis Laferrière [Thu, 7 Sep 2017 15:48:34 +0000 (11:48 -0400)]
core: protect access to _items in empty strings

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

6 years agoserialization: move serialization_core
Alexis Laferrière [Fri, 8 Sep 2017 00:45:41 +0000 (20:45 -0400)]
serialization: move serialization_core

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

6 years agocalculator: don't use fonts in the icon source
Alexis Laferrière [Thu, 7 Sep 2017 19:04:29 +0000 (15:04 -0400)]
calculator: don't use fonts in the icon source

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

6 years agoapp: add code example to data_store, http_request and ui
Alexis Laferrière [Thu, 7 Sep 2017 19:11:35 +0000 (15:11 -0400)]
app: add code example to data_store, http_request and ui

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

6 years agoapp: report errors in DataStore and fix a warning
Alexis Laferrière [Wed, 6 Sep 2017 19:46:59 +0000 (15:46 -0400)]
app: report errors in DataStore and fix a warning

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

6 years agoapp: make DataStore a class and refine on each platform
Alexis Laferrière [Wed, 6 Sep 2017 19:46:22 +0000 (15:46 -0400)]
app: make DataStore a class and refine on each platform

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

6 years agoapp: tweak UI API doc
Alexis Laferrière [Wed, 6 Sep 2017 15:50:49 +0000 (11:50 -0400)]
app: tweak UI API doc

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

6 years agoapp: update clients to use `root_window`
Alexis Laferrière [Wed, 6 Sep 2017 15:51:00 +0000 (11:51 -0400)]
app: update clients to use `root_window`

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

6 years agoapp: intro `root_window` to select the first visible window
Alexis Laferrière [Wed, 6 Sep 2017 13:37:15 +0000 (09:37 -0400)]
app: intro `root_window` to select the first visible window

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

6 years agostream: intro `BytesWriter` and `BytesReader`
Alexis Laferrière [Tue, 25 Jul 2017 14:20:27 +0000 (10:20 -0400)]
stream: intro `BytesWriter` and `BytesReader`

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

6 years agoapp: update UI example language and android style
Alexis Laferrière [Mon, 4 Sep 2017 22:21:57 +0000 (18:21 -0400)]
app: update UI example language and android style

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

6 years agohighlight: optionally print errors when highlighting
Alexis Laferrière [Thu, 7 Sep 2017 15:16:52 +0000 (11:16 -0400)]
highlight: optionally print errors when highlighting

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

6 years agoMerge: Nitmetric fixes
Jean Privat [Thu, 7 Sep 2017 14:49:00 +0000 (10:49 -0400)]
Merge: Nitmetric fixes

Avoid some nitmetric crashes

Pull-Request: #2533

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 agonitunit: update documentation for annotations
Alexandre Terrasa [Tue, 6 Jun 2017 05:18:45 +0000 (01:18 -0400)]
nitunit: update documentation for annotations

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

6 years agotests: update syntax tests
Alexandre Terrasa [Tue, 6 Jun 2017 18:57:58 +0000 (14:57 -0400)]
tests: update syntax tests

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

6 years agonitunit: migrate test generation to annotations
Alexandre Terrasa [Tue, 6 Jun 2017 05:18:01 +0000 (01:18 -0400)]
nitunit: migrate test generation to annotations

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

6 years agofrontend: disable warnings for test modules
Alexandre Terrasa [Tue, 6 Jun 2017 05:16:27 +0000 (01:16 -0400)]
frontend: disable warnings for test modules

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

6 years agosrc: migrate nitunits to annotations
Alexandre Terrasa [Tue, 6 Jun 2017 05:17:38 +0000 (01:17 -0400)]
src: migrate nitunits to annotations

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

6 years agolib: migrate nitunits to annotations
Alexandre Terrasa [Tue, 6 Jun 2017 05:19:51 +0000 (01:19 -0400)]
lib: migrate nitunits to annotations

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

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 agobytes: tweak doc to put forward the copy behavior of the slices
Alexis Laferrière [Tue, 25 Jul 2017 20:51:02 +0000 (16:51 -0400)]
bytes: tweak doc to put forward the copy behavior of the slices

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>