nit.git
7 years agonitweb: rewrite stars display
Alexandre Terrasa [Thu, 4 Aug 2016 18:48:03 +0000 (14:48 -0400)]
nitweb: rewrite stars display

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

7 years agonitweb: rewrite ratings to allow dimensions (like code, feature, examples...)
Alexandre Terrasa [Sun, 14 Aug 2016 21:46:13 +0000 (17:46 -0400)]
nitweb: rewrite ratings to allow dimensions (like code, feature, examples...)

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

7 years agonitweb: avoid linearization errors
Alexandre Terrasa [Thu, 18 Aug 2016 02:08:30 +0000 (22:08 -0400)]
nitweb: avoid linearization errors

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

7 years agoMerge: Fix model_json and nitweb
Jean Privat [Sat, 3 Dec 2016 13:11:30 +0000 (08:11 -0500)]
Merge: Fix model_json and nitweb

Was broken since #2312

* Migrate `model_json` to new serialization API
* Add tests to `model_json` to ensure this doesn't happen anymore
* Migrate `web` package and `nitweb` to new API

@xymus a lot of serialization for you. Note: for each entity, I needed two deserialization version `full` and no full. Wasn't sure on how to handle this concern properly with your API

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

7 years agonitweb: migrate to new json serialization API
Alexandre Terrasa [Fri, 4 Nov 2016 00:39:07 +0000 (20:39 -0400)]
nitweb: migrate to new json serialization API

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

7 years agomodel: add nitunit for model_json
Alexandre Terrasa [Wed, 23 Nov 2016 21:32:08 +0000 (16:32 -0500)]
model: add nitunit for model_json

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

7 years agomodel: migrate model_json to new serialization API
Alexandre Terrasa [Thu, 3 Nov 2016 23:02:23 +0000 (19:02 -0400)]
model: migrate model_json to new serialization API

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

7 years agoMerge: mongo: More queries
Jean Privat [Fri, 2 Dec 2016 15:13:46 +0000 (10:13 -0500)]
Merge: mongo: More queries

* Fix query prefixes
* Add Array related queries

Pull-Request: #2336

7 years agoMerge: nitweb: /random apply limit after random
Jean Privat [Fri, 2 Dec 2016 15:13:45 +0000 (10:13 -0500)]
Merge: nitweb: /random apply limit after random

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

Pull-Request: #2335

7 years agoMerge: src/model: collect package modules
Jean Privat [Fri, 2 Dec 2016 15:13:43 +0000 (10:13 -0500)]
Merge: src/model: collect package modules

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

Pull-Request: #2334

7 years agoMerge: lib/github: load more user data
Jean Privat [Fri, 2 Dec 2016 15:13:42 +0000 (10:13 -0500)]
Merge: lib/github: load more user data

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

Pull-Request: #2333

7 years agoMerge: lib/math: fix some nitunits
Jean Privat [Fri, 2 Dec 2016 15:13:40 +0000 (10:13 -0500)]
Merge: lib/math: fix some nitunits

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

Pull-Request: #2332

7 years agoMerge: nitunit: set NIT_TESTING_PATH
Jean Privat [Fri, 2 Dec 2016 15:13:38 +0000 (10:13 -0500)]
Merge: nitunit: set NIT_TESTING_PATH

When working with test suites, one can now use `NIT_TESTING_PATH` to retrieve the test suite path.

It can be used to access files based on the current test suite location:

~~~nit
class MyTest
super TestSuite

    fun test_suite_path do
        assert "NIT_TESTING_PATH".environ.basename == "my_test_suite.nit"
    end
end
~~~

Useful for test suites based on model loading like in #2327.

Pull-Request: #2331

7 years agomongo: add array related queries
Alexandre Terrasa [Mon, 28 Nov 2016 22:30:42 +0000 (17:30 -0500)]
mongo: add array related queries

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

7 years agomongo: fix query prefixes
Alexandre Terrasa [Mon, 28 Nov 2016 22:30:19 +0000 (17:30 -0500)]
mongo: fix query prefixes

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

7 years agonitweb: /random apply limit after random
Alexandre Terrasa [Wed, 31 Aug 2016 14:27:05 +0000 (10:27 -0400)]
nitweb: /random apply limit after random

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

7 years agosrc/model: collect package modules
Alexandre Terrasa [Wed, 31 Aug 2016 14:26:29 +0000 (10:26 -0400)]
src/model: collect package modules

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

7 years agolib/github: load more user data
Alexandre Terrasa [Mon, 28 Nov 2016 22:10:43 +0000 (17:10 -0500)]
lib/github: load more user data

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

7 years agolib/math: fix some nitunits
Alexandre Terrasa [Wed, 31 Aug 2016 14:03:24 +0000 (10:03 -0400)]
lib/math: fix some nitunits

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

7 years agoman: document `NIT_TESTING_PATH`
Alexandre Terrasa [Mon, 28 Nov 2016 21:11:59 +0000 (16:11 -0500)]
man: document `NIT_TESTING_PATH`

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

7 years agotests: test nitunit `NIT_TESTING_PATH`
Alexandre Terrasa [Mon, 28 Nov 2016 21:11:38 +0000 (16:11 -0500)]
tests: test nitunit `NIT_TESTING_PATH`

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

7 years agonitunit: set NIT_TESTING_PATH before running a test suite
Alexandre Terrasa [Mon, 28 Nov 2016 21:11:16 +0000 (16:11 -0500)]
nitunit: set NIT_TESTING_PATH before running a test suite

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

7 years agonitunit: remove warnings from testing_suite (and uniformize the style)
Alexandre Terrasa [Mon, 28 Nov 2016 21:10:47 +0000 (16:10 -0500)]
nitunit: remove warnings from testing_suite (and uniformize the style)

Haters gonna hate.

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

7 years agonitunit: toolcontext set `NIT_TESTING_PATH`
Alexandre Terrasa [Mon, 28 Nov 2016 21:09:55 +0000 (16:09 -0500)]
nitunit: toolcontext set `NIT_TESTING_PATH`

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

7 years agonitunit: remove warnings from testing_base
Alexandre Terrasa [Mon, 28 Nov 2016 21:09:15 +0000 (16:09 -0500)]
nitunit: remove warnings from testing_base

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

7 years agoMerge: Updates some tests and the tests.sh script for compatibility with Windows
Jean Privat [Thu, 24 Nov 2016 19:21:56 +0000 (14:21 -0500)]
Merge: Updates some tests and the tests.sh script for compatibility with Windows

This is part of the ongoing effort to make Nit work under Windows using msys2 / mingw64, this time we look at tests and support tools.

* Tweak tests.sh to work correctly on Windows: diff ignore CR, don't use -s on hostname from coreutils and don't use the $tmp variable as it overwrites an environment variable.
* Make the very badly named test a bit less bad so its path is valid on Windows.
* Fix the pkg-config annotation behavior on multiple arguments and fix its broken tests. (This is not directly related to Windows support, but valid tests will help to debug.)
* As a bonus, fix the repeated typo *boostrap*.

Pull-Request: #2330
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>

7 years agosrc: fix the scary typo boostrap
Alexis Laferrière [Sat, 19 Nov 2016 18:31:39 +0000 (13:31 -0500)]
src: fix the scary typo boostrap

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

7 years agotests: fix test_annot_pkgconfig.nit so it actually works
Alexis Laferrière [Thu, 17 Nov 2016 14:22:25 +0000 (09:22 -0500)]
tests: fix test_annot_pkgconfig.nit so it actually works

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

7 years agopkgconfig annot: try all args before giving up
Alexis Laferrière [Sat, 19 Nov 2016 00:26:36 +0000 (19:26 -0500)]
pkgconfig annot: try all args before giving up

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

7 years agotests.sh: don't use -s on coreutils hostname
Alexis Laferrière [Thu, 17 Nov 2016 10:34:47 +0000 (05:34 -0500)]
tests.sh: don't use -s on coreutils hostname

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

7 years agotests.sh: rename $tmp to avoid conflict with the $tmp env var
Alexis Laferrière [Thu, 17 Nov 2016 10:19:48 +0000 (05:19 -0500)]
tests.sh: rename $tmp to avoid conflict with the $tmp env var

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

7 years agotests.sh: ignore end of line characters
Alexis Laferrière [Tue, 16 Aug 2016 15:22:02 +0000 (11:22 -0400)]
tests.sh: ignore end of line characters

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

7 years agotests: make the very bad name test compatible with windows
Alexis Laferrière [Sat, 19 Nov 2016 00:35:46 +0000 (19:35 -0500)]
tests: make the very bad name test compatible with windows

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

7 years agoMerge: Delete the debugger from the interpreter
Jean Privat [Fri, 11 Nov 2016 18:46:05 +0000 (13:46 -0500)]
Merge: Delete the debugger from the interpreter

This PR removes the entire debugger from the interpreter including the client/server debugger. The debugger is not maintained and was never fully completed in the first place. There is a consensus that it should be rewritten from scratch if needed.

As discussed with @R4PaSs and @privat.

Pull-Request: #2329
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

7 years agoMerge: lib/github: update unit test for change in Github API behavior
Jean Privat [Fri, 11 Nov 2016 18:46:03 +0000 (13:46 -0500)]
Merge: lib/github: update unit test for change in Github API behavior

Update a Github API unit test for recent changes in the remote API behavior. I couldn't find any information on this change, so it may also be a temporary problem.

This commit was originally in #2326.

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

7 years agonit: purge the debugger from the interpreter
Alexis Laferrière [Wed, 9 Nov 2016 18:28:42 +0000 (13:28 -0500)]
nit: purge the debugger from the interpreter

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

7 years agolib/github: update for Github API changes
Alexis Laferrière [Sat, 29 Oct 2016 14:11:00 +0000 (10:11 -0400)]
lib/github: update for Github API changes

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

7 years agoMerge: pkgconfig annotation: improve error on missing dev package
Jean Privat [Wed, 2 Nov 2016 12:28:45 +0000 (08:28 -0400)]
Merge: pkgconfig annotation: improve error on missing dev package

This is an attempt to improve the error message on a missing development package. The current error stumps everyone on the first occurrence. The new version puts an emphasis on three things:
- it needs the _dev_ package,
- a possible solution by mentioning apt-get and brew,  and
- that it may be a problem with pkg-config itself.

I chose to mention apt-get and brew as I consider that they are the best known package manager on Linux and macOS..

Pull-Request: #2325
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

7 years agopkgconfig: more precise error on missing dev package
Alexis Laferrière [Mon, 24 Oct 2016 17:08:31 +0000 (13:08 -0400)]
pkgconfig: more precise error on missing dev package

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

7 years agoMerge: serialization: subtype check attributes & serialize part of the metamodel
Jean Privat [Mon, 24 Oct 2016 18:48:10 +0000 (14:48 -0400)]
Merge: serialization: subtype check attributes & serialize part of the metamodel

This PR is a bit out of the ordinary, it tackles 2 issues with serialization:

1. Avoid deserializing unwanted types to fix a security hole where a refined attribute setter could be abused to cause side effects in the running program.

   The solution inserts 2 checks in the deserialization process, for JSON only:

   1. Check the dynamic type of the Nit object to create from a JSON object against the static type of the attribute. It is created and deserialized only if the dynamic type is a subtype of the static type. This check is activated by default, it can be turned off for some rare use case.

   2. A whitelist lists the accepted dynamic types to deserialize. It can add an extra level of security above the subtype check, or manually replace it when it can't be used. If the whitelist is empty, this check is disabled, the default.

   Pseudo-code algo:
   ~~~
   for name, value in json_object_as_hash_map do
       if value isa json_object_as_hash_map do
           # Existing: find the dynamic type from __class, class_name_heuristic or fallbacks on the static type
           var dynamic_type = heuristic_dynamic_type(value)

           # New
           check whitelist.has(dynamic_type)
           check dynamic_type isa static_type
       end
   end
   ~~~

   Note that attributes typed by `Object` still accept anything (as expected). But there is also a security hole with attributes typed by a virtual type bound to `Object`. We don't have runtime access to the precise type of the virtual attribute so we always use the upper bound `Object`. So `Array` and the like are still a vulnerable point.

2. Ask for a specific static type at serialization while preserving polymorphism.

   The solution adds an argument `static_type` to `JsonDeserializer::deserialize` to ask for a specific type. The deserialized object will be a subclass of `static_type`, or `null` on error.

   This should be preferred to calling directly `from_deserializer` as it allows for subclasses and return null on fatal errors.

   ~~~
   var engine = new JsonDeserializer("""{"item": 4}""")
   var obj = engine.deserialize("Ref[Int]")
   assert engine.errors.not_empty
   assert obj isa Ref[Int]
   ~~~

These features rely on a new intern service `class_inheritance_metamodel_json` (I'm not convinced by the name but at least it is private). This method returns a `POSet[String]` serialized to JSON representing the inheritance graph of the running program. The compiler stores the JSON string in the generated C code, it takes about 200kb for a small program.

It would be pretty easy to add other services to read the metamodel, as needed. However, there is a strong coupling between the JsonDeserializer and `class_inheritance_metamodel_json`, this could be solved by adding a few modules with abstract services.

Future work:
* Do the same in the binary serialization engine.
* Move the metamodel services out of the `json` package.
* With a runtime access to the precise type of virtual types (`V.class_name`),
  fix hole with attributes bound to a `nullable Object` static type.
* Do a full subtype check, not only subclass check (for generic classes).
* Use full qualified names in the serialized metamodel to avoid name conflicts.

@ppepos Did I correctly isolate the security issue? There is an example of the vulnerability in the test.

Pull-Request: #2311
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Reviewed-by: Jean Privat <jean@pryen.org>

7 years agoMerge: nitcorn: handle SIGINT and SIGTERM
Jean Privat [Mon, 24 Oct 2016 13:35:10 +0000 (09:35 -0400)]
Merge: nitcorn: handle SIGINT and SIGTERM

Intercept SIGINT and SIGTERM to close the server cleanly. The first signal request a clean exit from libevent, so it waits to complete the active events before closing. The second signal reverts to the default signal handler and quits instantly.

Fix #2294.

Pull-Request: #2323
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Ait younes Mehdi Adel <overpex@gmail.com>

7 years agoMerge: nitcorn: decode GET args from percent encoding
Jean Privat [Mon, 24 Oct 2016 13:35:07 +0000 (09:35 -0400)]
Merge: nitcorn: decode GET args from percent encoding

While POST data was decoded from percent encoding, GET args were not. Some clients (`shibuqam`) manually decoded that args while others (`benitlux`) hung on requests with spaces.

There is still an issue in the HTTP request parsing where request URL with a space are broken. I'm not fixing this right away because there is no current issue associated to this problem and I have a larger rewrite of nitcorn in the works that will solve this.

Pull-Request: #2322

7 years agoMerge: nitrestful: rename resources and restrict HTTP methods
Jean Privat [Mon, 24 Oct 2016 13:35:04 +0000 (09:35 -0400)]
Merge: nitrestful: rename resources and restrict HTTP methods

The `restful` annotation makes a method accessible by HTTP requests. It saves a ton of boilerplate code by taking care of simple routes, deserializing the arguments and handling error management. It is already in use by the Benitlux server.

This PR adds documentation for the `restful` annotation and updates the example. It also improves the `restful` annotations by adding the support for two kind of arguments:

* String literals rename or add an alias for the HTTP resource. By default, the name of the HTTP resource is the name of the `restful` method. The first string literal replaces the default name, while additional strings literals add aliases.

* Ids such as `GET`, `POST`, `PUT` and `DELETE` restrict which HTTP methods are accepted. By default, all HTTP methods are accepted.

Once #2311 is merged, we will be able to update `nitrestful` to better support plain JSON objects as input.

Pull-Request: #2321

7 years agometrics: don't visit annotation nodes
Alexis Laferrière [Thu, 20 Oct 2016 05:33:41 +0000 (01:33 -0400)]
metrics: don't visit annotation nodes

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

7 years agolibevent: fix compatibility with light FFI and global/semi-global
Alexis Laferrière [Tue, 18 Oct 2016 20:18:55 +0000 (16:18 -0400)]
libevent: fix compatibility with light FFI and global/semi-global

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

7 years agonitc: only serialize the type model if `json::serialization_read` is imported
Alexis Laferrière [Fri, 14 Oct 2016 20:02:41 +0000 (16:02 -0400)]
nitc: only serialize the type model if `json::serialization_read` is imported

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

7 years agotests: update error_unk_class2 sav with change in linearisation
Alexis Laferrière [Mon, 12 Sep 2016 20:02:31 +0000 (16:02 -0400)]
tests: update error_unk_class2 sav with change in linearisation

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

7 years agotests: update nitserial test
Alexis Laferrière [Mon, 12 Sep 2016 17:25:24 +0000 (13:25 -0400)]
tests: update nitserial test

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

7 years agotests: add test_json_deserilizer_safe
Alexis Laferrière [Sat, 10 Sep 2016 17:56:21 +0000 (13:56 -0400)]
tests: add test_json_deserilizer_safe

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

7 years agolib serialization: `deserialize` accepts the name of the static type as argument
Alexis Laferrière [Sat, 10 Sep 2016 20:41:06 +0000 (16:41 -0400)]
lib serialization: `deserialize` accepts the name of the static type as argument

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

7 years agojson::serialization: check before deserializing an object if it is a subtype
Alexis Laferrière [Fri, 14 Oct 2016 19:22:50 +0000 (15:22 -0400)]
json::serialization: check before deserializing an object if it is a subtype

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

7 years agojson::serialization: intro services to get the class hierarchy from the engine
Alexis Laferrière [Fri, 14 Oct 2016 19:21:09 +0000 (15:21 -0400)]
json::serialization: intro services to get the class hierarchy from the engine

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

7 years agojson::serialization: whitelist deserializable classes
Alexis Laferrière [Fri, 14 Oct 2016 19:19:44 +0000 (15:19 -0400)]
json::serialization: whitelist deserializable classes

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

7 years agonitc & niti: support intern method to generate serialization_metadata
Alexis Laferrière [Thu, 8 Sep 2016 17:32:00 +0000 (13:32 -0400)]
nitc & niti: support intern method to generate serialization_metadata

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

7 years agointerpreter: remove duplicated intern methods
Alexis Laferrière [Sat, 10 Sep 2016 18:35:45 +0000 (14:35 -0400)]
interpreter: remove duplicated intern methods

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

7 years agosrc: complete some missing doc
Alexis Laferrière [Thu, 8 Sep 2016 17:31:15 +0000 (13:31 -0400)]
src: complete some missing doc

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

7 years agolib/poset: implement serialization compatible with nith
Alexis Laferrière [Thu, 8 Sep 2016 17:30:37 +0000 (13:30 -0400)]
lib/poset: implement serialization compatible with nith

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

7 years agolib/poset: fix warnings and a typo
Alexis Laferrière [Thu, 8 Sep 2016 18:35:25 +0000 (14:35 -0400)]
lib/poset: fix warnings and a typo

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

7 years agofrontend serialization: resolve type before using their static name
Alexis Laferrière [Sat, 10 Sep 2016 18:27:23 +0000 (14:27 -0400)]
frontend serialization: resolve type before using their static name

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

7 years agofrontend serialization: don't create `core_serialize_to` if it exists
Alexis Laferrière [Sat, 10 Sep 2016 14:50:55 +0000 (10:50 -0400)]
frontend serialization: don't create `core_serialize_to` if it exists

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

7 years agojson::serialization: fix use null when an instance is not serializable
Alexis Laferrière [Fri, 14 Oct 2016 19:18:23 +0000 (15:18 -0400)]
json::serialization: fix use null when an instance is not serializable

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

7 years agonitcorn: clean exit on SIGINT & SIGTERM
Alexis Laferrière [Wed, 12 Oct 2016 17:36:42 +0000 (13:36 -0400)]
nitcorn: clean exit on SIGINT & SIGTERM

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

7 years agolibevent: intro basic event and signals support
Alexis Laferrière [Wed, 12 Oct 2016 19:07:50 +0000 (15:07 -0400)]
libevent: intro basic event and signals support

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

7 years agolibevent: rename `exit_loop` and `destroy` to their C names
Alexis Laferrière [Thu, 13 Oct 2016 17:51:34 +0000 (13:51 -0400)]
libevent: rename `exit_loop` and `destroy` to their C names

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

7 years agolib/signals: silence C warning
Alexis Laferrière [Wed, 12 Oct 2016 17:36:27 +0000 (13:36 -0400)]
lib/signals: silence C warning

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

7 years agonitcorn: test a url-encoded GET arg with a space
Alexis Laferrière [Wed, 12 Oct 2016 16:47:13 +0000 (12:47 -0400)]
nitcorn: test a url-encoded GET arg with a space

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

7 years agobenitlux: percent encode GET args
Alexis Laferrière [Wed, 12 Oct 2016 15:55:29 +0000 (11:55 -0400)]
benitlux: percent encode GET args

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

7 years agoshibuqam: we can use `string_arg` directly
Alexis Laferrière [Wed, 12 Oct 2016 15:45:06 +0000 (11:45 -0400)]
shibuqam: we can use `string_arg` directly

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

7 years agonitcorn: fix decoding GET args from percent encoding
Alexis Laferrière [Wed, 12 Oct 2016 15:44:37 +0000 (11:44 -0400)]
nitcorn: fix decoding GET args from percent encoding

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

7 years agonitrestful: update tests results
Alexis Laferrière [Tue, 11 Oct 2016 20:09:14 +0000 (16:09 -0400)]
nitrestful: update tests results

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

7 years agonitcorn: document the `restful` annotation
Alexis Laferrière [Tue, 11 Oct 2016 18:34:05 +0000 (14:34 -0400)]
nitcorn: document the `restful` annotation

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

7 years agonitcorn: update nitrestful example
Alexis Laferrière [Tue, 11 Oct 2016 03:01:52 +0000 (23:01 -0400)]
nitcorn: update nitrestful example

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

7 years agonitrestful: support custom resource name and HTTP methods/verbs
Alexis Laferrière [Mon, 30 Nov 2015 17:37:27 +0000 (12:37 -0500)]
nitrestful: support custom resource name and HTTP methods/verbs

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

7 years agonitrestful: fix naming of "resources" as recommended
Alexis Laferrière [Tue, 11 Oct 2016 01:54:59 +0000 (21:54 -0400)]
nitrestful: fix naming of "resources" as recommended

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

7 years agolibevent: intro enable_debug_mode
Alexis Laferrière [Tue, 11 Oct 2016 01:41:42 +0000 (21:41 -0400)]
libevent: intro enable_debug_mode

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

7 years agoMerge: iOS: complete support for the UI API
Jean Privat [Fri, 7 Oct 2016 19:40:30 +0000 (15:40 -0400)]
Merge: iOS: complete support for the UI API

This PR complete the iOS support of the _app.nit_ UI API and fixes a few bugs:

* Fix `ListLayout` (the scrolling view) so its content fits in the horizontal limits of the screen. (The solution was the "-0-" in the constraint string!)
* Fix detecting when the user taps the system "back" button to correctly resume the previous window.
* Implement `size=` and `align=` on `TextInput` and `Button`. There is some code duplication because the Objective-C properties are not the same.
* Add `TextInput::placeholder=`, the placeholder is often used to identify a text field without using a label on iOS.
* Intro more color related services to extern classes, including a constructor to get the default light gray color used in the background of system menus.
* Bypass the Unicode validity checks so that Unicode characters are left as is, a workaround for #1945. This will cause problems on invalid Unicode strings, but it does work for valid Unicode strings.
* As a bonus, update the resolutions of the icons generated by `inkscape_tools`. Dropping support for older iOS versions and adding support for newer versions.

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

7 years agoMerge: android: click event on button release, better errors and safer `JavaString...
Jean Privat [Fri, 7 Oct 2016 19:40:27 +0000 (15:40 -0400)]
Merge: android: click event on button release, better errors and safer `JavaString::to_s`

Some small tweaks to the Android support:

* `JavaString::to_s` used to crash (at the JNI level) if the associated Java string was null. This was a counterintuitive behavior when the Nit object is non-nullable. This PR prevents this error by returning something similar to the default `Object::to_s` when the underlying Java value is null (for `JavaString` and others). This makes it crash proof, but one should still check if `JavaString::is_java_null` before using the value returned by `to_s` when an actual string is expected.

* Some Java exceptions raised by the Android implementation of `http_get` do not have a message. This PR looks through the causes of such exceptions to find the first available message.

* Also, fix `on_click & ButtonPressEvent` to be raised only when a button is released (instead of at the initial touch).

Pull-Request: #2319
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Reviewed-by: Ait younes Mehdi Adel <overpex@gmail.com>

7 years agoinkscape_tools: update the format of icons generated of iOS
Alexis Laferrière [Fri, 23 Sep 2016 15:00:12 +0000 (11:00 -0400)]
inkscape_tools: update the format of icons generated of iOS

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

7 years agoios: don't force spacing between elements of layouts
Alexis Laferrière [Mon, 26 Sep 2016 17:32:52 +0000 (13:32 -0400)]
ios: don't force spacing between elements of layouts

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

7 years agoios: intro services for UIColor, UILabel & UITextField
Alexis Laferrière [Sun, 25 Sep 2016 23:18:52 +0000 (19:18 -0400)]
ios: intro services for UIColor, UILabel & UITextField

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

7 years agoios: workaround for unicode issue #1945
Alexis Laferrière [Sun, 25 Sep 2016 17:28:44 +0000 (13:28 -0400)]
ios: workaround for unicode issue #1945

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

7 years agoios: intro custom view controller and catch back button press
Alexis Laferrière [Fri, 23 Sep 2016 01:10:13 +0000 (21:10 -0400)]
ios: intro custom view controller and catch back button press

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

7 years agoios: fix ListLayout to fit horizontally
Alexis Laferrière [Thu, 22 Sep 2016 16:37:22 +0000 (12:37 -0400)]
ios: fix ListLayout to fit horizontally

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

7 years agoios: redirect prints to NSLog (printf is no longer an output of the simulator)
Alexis Laferrière [Fri, 23 Sep 2016 01:09:38 +0000 (21:09 -0400)]
ios: redirect prints to NSLog (printf is no longer an output of the simulator)

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

7 years agoios: duplicate full implementation of `size= & align=` in TextInput
Alexis Laferrière [Fri, 9 Sep 2016 14:39:42 +0000 (10:39 -0400)]
ios: duplicate full implementation of `size= & align=` in TextInput

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

7 years agoios: Button relay `size= & align=` to its `title_label`
Alexis Laferrière [Fri, 9 Sep 2016 14:39:00 +0000 (10:39 -0400)]
ios: Button relay `size= & align=` to its `title_label`

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

7 years agoios: refactor `Label::size= & align=` services implementation
Alexis Laferrière [Fri, 9 Sep 2016 14:37:55 +0000 (10:37 -0400)]
ios: refactor `Label::size= & align=` services implementation

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

7 years agoMerge: iOS: fix compilation problems, warnings and the Benitlux ios-release rule
Jean Privat [Thu, 29 Sep 2016 19:45:07 +0000 (15:45 -0400)]
Merge: iOS: fix compilation problems, warnings and the Benitlux ios-release rule

General fixes for the iOS support:
* Report errors on `rmdir`, this depends on the fix #2309.
* Fix release mode compilation, the path to the binary was wrong.
* Fix the ios-release rule of Benitlux to use the release mode, contact the right server, and keep the generated files to use from XCode.
* Finally silence the normal output of `xcodebuild`. This looks like a new feature of XCode 8!
* Fixed a few warnings raised by clang.

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

7 years agojava: don't crash on `to_s` when not null in Nit (even if null in Java)
Alexis Laferrière [Tue, 27 Sep 2016 14:49:56 +0000 (10:49 -0400)]
java: don't crash on `to_s` when not null in Nit (even if null in Java)

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

7 years agoandroid: trigger click event on button release
Alexis Laferrière [Wed, 28 Sep 2016 18:42:14 +0000 (14:42 -0400)]
android: trigger click event on button release

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

7 years agoandroid::http_request: fix exception handling
Alexis Laferrière [Tue, 27 Sep 2016 13:01:09 +0000 (09:01 -0400)]
android::http_request: fix exception handling

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

7 years agotests: skip postgres tests on macOS
Alexis Laferrière [Tue, 27 Sep 2016 20:21:52 +0000 (16:21 -0400)]
tests: skip postgres tests on macOS

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

7 years agoMerge: lib/json: unify the writing API using serialization only
Jean Privat [Fri, 23 Sep 2016 19:26:44 +0000 (15:26 -0400)]
Merge: lib/json: unify the writing API using serialization only

Some context first, before this PR, there were 2 API to write JSON:
* The module `static` provided `to_json` and `to_pretty_json` which supported writing only basic Nit types associated with JSON types and objects with a manually implemented `to_json`.
* The module `serialization` provides `serialize_to_json` which supports all `Serializable` types, a superset of the JSON types, and where standard Nit objects are serialized to JSON objects by generated code.

The advantages of the `serialization` API are:
* Objects written to JSON with some metadata (mainly the name of the Nit type) can be deserialized back to Nit objects.
* The boilerplate code to write the attributes is generated, usually a single `is serialize` after the module declarations does the trick. (`core_serialize_to`, the equivalent of `to_json`, doesn't have to be implemented in each classes, the generated version is usually enough.)
* Implementing `core_serialize_to` (or leaving it to the generated code) instead of `to_json` makes the object compatible with both the JSON and binary serialization services.
* In general, the `serialization` API allows to easily write Nit objects to JSON and build JSON objects using `Map` instances:
~~~
import json::serialization

class Person
    serialize

    var name: String
    var year_of_birth: Int
end

var bob = new Person("Bob", 1986)
assert bob.serialize_to_json(pretty=true, plain=true) == """
{
    "name": "Bob",
    "year_of_birth": 1986
}"""

var charlie = new Map[String, nullable Serializable]
charlie["name"] = "Charlie"
charlie["year_of_birth"] = 1968
assert charlie.serialize_to_json(pretty=true, plain=true) == """
{
    "name": "Charlie",
    "year_of_birth": 1968
}"""
~~~

So this PR drops the `static` writing API, and replaces its services (`to_json` and `to_pretty_json`) by aliases in `serialization`. Some subclasses have been updated to implement the recursive `serialize_to` instead of the `to_json`, the changes are minimal to avoid breaking any software, but they are not optimal. The result is a single JSON writing API!

The generated JSON should not have changed much (maybe a bit less or more white spaces), except for some error messages which were translated to invalid JSON and are now serialized to a valid JSON object.

I expect some tests to fail as this is a big change, and clients of the `json::static` writing services (@morriar) should probably double check my changes to their code.

In the future, I'm thinking of dropping the name `serialize_to_json` and `to_pretty_json` and move the optionnal parameters to `to_json`. The JSON module also really needs refactoring at this point.

Pull-Request: #2312
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

7 years agoMerge: nitcorn: possible fix for the bug on input with unicode
Jean Privat [Fri, 23 Sep 2016 03:07:09 +0000 (23:07 -0400)]
Merge: nitcorn: possible fix for the bug on input with unicode

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

7 years agotests: iOS app have one more file
Alexis Laferrière [Thu, 22 Sep 2016 13:06:22 +0000 (09:06 -0400)]
tests: iOS app have one more file

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

7 years agonitcorn: fix input buffer containing unicode
Alexis Laferrière [Wed, 21 Sep 2016 20:08:25 +0000 (16:08 -0400)]
nitcorn: fix input buffer containing unicode

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

7 years agobenitlux: fix ios-release rule and keep the compiled files for XCode GUI
Alexis Laferrière [Fri, 9 Sep 2016 12:39:55 +0000 (08:39 -0400)]
benitlux: fix ios-release rule and keep the compiled files for XCode GUI

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

7 years agolib: fix clang warnings in md5 and pthreads
Alexis Laferrière [Wed, 21 Sep 2016 16:45:34 +0000 (12:45 -0400)]
lib: fix clang warnings in md5 and pthreads

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

7 years agosrc: `exec_and_check` print to stderr
Alexis Laferrière [Fri, 9 Sep 2016 14:35:19 +0000 (10:35 -0400)]
src: `exec_and_check` print to stderr

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

7 years agonitc iOS: quiet output of `xcodebuild`
Alexis Laferrière [Wed, 21 Sep 2016 16:45:54 +0000 (12:45 -0400)]
nitc iOS: quiet output of `xcodebuild`

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