nit.git
8 years agolib: Fix serialization issue with string-oriented typing
Lucas Bajolet [Mon, 25 Apr 2016 15:00:12 +0000 (11:00 -0400)]
lib: Fix serialization issue with string-oriented typing

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agotests: Updated sav for old tests
Lucas Bajolet [Mon, 25 Apr 2016 14:52:40 +0000 (10:52 -0400)]
tests: Updated sav for old tests

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agolib/core: Faster access to length in ropes
Lucas Bajolet [Fri, 22 Apr 2016 20:08:31 +0000 (16:08 -0400)]
lib/core: Faster access to length in ropes

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agolib/core: Made FlatString abstract and added fast version for ASCII-only Strings
Lucas Bajolet [Fri, 22 Apr 2016 19:14:53 +0000 (15:14 -0400)]
lib/core: Made FlatString abstract and added fast version for ASCII-only Strings

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: model_collect: add more services
Jean Privat [Fri, 22 Apr 2016 02:21:48 +0000 (22:21 -0400)]
Merge: model_collect: add more services

Just some services that work on flattened views of the model that I will need soon.

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

8 years agoMerge: Codec refactor
Jean Privat [Thu, 21 Apr 2016 21:51:21 +0000 (17:51 -0400)]
Merge: Codec refactor

Sub-part of #2006 since @privat asked for it to be split, here's one part concerning the addition of a few services to NativeString and Byte, along with the refactor of the Codec API

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

8 years agoMerge: Pack Strings
Jean Privat [Thu, 21 Apr 2016 21:51:19 +0000 (17:51 -0400)]
Merge: Pack Strings

Added convenience feature to `Text` objects: `pack`.

These new methods pack the content of a `Text` object into an array of `n` elements of length up to `ln`.

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

8 years agoMerge: Poset: add clone, ==, hash and sub
Jean Privat [Thu, 21 Apr 2016 21:51:14 +0000 (17:51 -0400)]
Merge: Poset: add clone, ==, hash and sub

Extends the POSet class with some useful methods to compare and (partially) copy posets.

Pull-Request: #2029
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agomodel_collect: collect MClass inits
Alexandre Terrasa [Tue, 19 Apr 2016 01:18:35 +0000 (21:18 -0400)]
model_collect: collect MClass inits

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

8 years agomodel_collect: collect all MClass inherited methods
Alexandre Terrasa [Tue, 19 Apr 2016 01:18:21 +0000 (21:18 -0400)]
model_collect: collect all MClass inherited methods

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

8 years agomodel_collect: collect importation poset for modules
Alexandre Terrasa [Wed, 20 Apr 2016 23:46:18 +0000 (19:46 -0400)]
model_collect: collect importation poset for modules

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

8 years agomodel_collect: collect more on MModule hierarchy
Alexandre Terrasa [Wed, 20 Apr 2016 23:46:01 +0000 (19:46 -0400)]
model_collect: collect more on MModule hierarchy

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

8 years agomodel_views: build posets from mentities lists
Alexandre Terrasa [Fri, 18 Dec 2015 05:21:16 +0000 (00:21 -0500)]
model_views: build posets from mentities lists

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

8 years agoMerge branch 'subposet' of https://github.com/privat/mynit into privat-subposet
Alexandre Terrasa [Thu, 21 Apr 2016 21:35:02 +0000 (17:35 -0400)]
Merge branch 'subposet' of https://github.com/privat/mynit into privat-subposet

8 years agotests: Added ISO8859-1 codec test
Lucas Bajolet [Thu, 21 Apr 2016 15:37:48 +0000 (11:37 -0400)]
tests: Added ISO8859-1 codec test

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoCodecs: Refactor API
Lucas Bajolet [Tue, 5 Apr 2016 20:39:02 +0000 (16:39 -0400)]
Codecs: Refactor API

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agolib/core: Added packing methods to `Text`
Lucas Bajolet [Thu, 21 Apr 2016 15:32:10 +0000 (11:32 -0400)]
lib/core: Added packing methods to `Text`

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agolib/poset: add == and hash
Jean Privat [Thu, 21 Apr 2016 13:45:40 +0000 (09:45 -0400)]
lib/poset: add == and hash

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

8 years agoMerge: Fix more warnings
Jean Privat [Thu, 21 Apr 2016 13:20:45 +0000 (09:20 -0400)]
Merge: Fix more warnings

Everything is in the title, for the algorithm see #2027.

Spam box: @R4PaSs @xymus @privat and even @BlackMinou for ballz

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

8 years agoMerge: nitweb: uml graphs route
Jean Privat [Thu, 21 Apr 2016 13:20:39 +0000 (09:20 -0400)]
Merge: nitweb: uml graphs route

Allows nitweb to display UML.

Thanks @R4PaSs!

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

8 years agoMerge: lib/core/bytes: add `Int::to_bytes` and `Bytes::to_i`
Jean Privat [Thu, 21 Apr 2016 13:20:36 +0000 (09:20 -0400)]
Merge: lib/core/bytes: add `Int::to_bytes` and `Bytes::to_i`

More nice services on bytes.

Pull-Request: #2013
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agolib/poset: make POSet cCloneable
Jean Privat [Thu, 21 Apr 2016 01:33:07 +0000 (21:33 -0400)]
lib/poset: make POSet cCloneable

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

8 years agolib/poset: add `sub` to build induced subposets
Jean Privat [Thu, 21 Apr 2016 01:32:21 +0000 (21:32 -0400)]
lib/poset: add `sub` to build induced subposets

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

8 years agonitweb: add /uml/:namespace route
Alexandre Terrasa [Wed, 20 Apr 2016 22:54:47 +0000 (18:54 -0400)]
nitweb: add /uml/:namespace route

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

8 years agolib/template: fix init with signature warning
Alexandre Terrasa [Wed, 20 Apr 2016 06:33:32 +0000 (02:33 -0400)]
lib/template: fix init with signature warning

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

8 years agolib: fix useless redef signature warnings
Alexandre Terrasa [Wed, 20 Apr 2016 06:33:00 +0000 (02:33 -0400)]
lib: fix useless redef signature warnings

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

8 years agolib: fix more call on nullable receiver warnings
Alexandre Terrasa [Wed, 20 Apr 2016 06:32:39 +0000 (02:32 -0400)]
lib: fix more call on nullable receiver warnings

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

8 years agolib: missing fix documentation warnings
Alexandre Terrasa [Wed, 20 Apr 2016 06:31:59 +0000 (02:31 -0400)]
lib: missing fix documentation warnings

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

8 years agosrc/doc: fix useless signature in redef warnings
Alexandre Terrasa [Wed, 20 Apr 2016 06:38:38 +0000 (02:38 -0400)]
src/doc: fix useless signature in redef warnings

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

8 years agosrc/doc: fix call on nullable receiver warnings
Alexandre Terrasa [Wed, 20 Apr 2016 06:38:15 +0000 (02:38 -0400)]
src/doc: fix call on nullable receiver warnings

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

8 years agoexamples/mnit_ballz: fix call on nullable receiver warnings
Alexandre Terrasa [Wed, 20 Apr 2016 06:37:33 +0000 (02:37 -0400)]
examples/mnit_ballz: fix call on nullable receiver warnings

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

8 years agocontrib: fix call on nullable receiver warnings
Alexandre Terrasa [Wed, 20 Apr 2016 06:37:09 +0000 (02:37 -0400)]
contrib: fix call on nullable receiver warnings

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

8 years agocontrib: fix useless signature in redef warning
Alexandre Terrasa [Wed, 20 Apr 2016 06:36:31 +0000 (02:36 -0400)]
contrib: fix useless signature in redef warning

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

8 years agocontrib/inkscape_tools: fix weird parenthesis
Alexandre Terrasa [Wed, 20 Apr 2016 22:40:33 +0000 (18:40 -0400)]
contrib/inkscape_tools: fix weird parenthesis

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

8 years agoMerge: nitcorn: fix path resolution for vararg routes
Jean Privat [Wed, 20 Apr 2016 17:22:02 +0000 (13:22 -0400)]
Merge: nitcorn: fix path resolution for vararg routes

Routes with parameters like `/blog/articles/:articleId` where not matched correctly.

It worked until today and I'm not really sure how? Anyway, this PR resolve the route with request parameters before performing the match.

Also done some cleaning in warnings and doc.

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

8 years agoMerge: lib/core: fix `Text::is_int`
Jean Privat [Wed, 20 Apr 2016 17:22:01 +0000 (13:22 -0400)]
Merge: lib/core: fix `Text::is_int`

Fix #2019, `is_int` was always returning true. It was caused by the use of the wrong local variable.

Ping @R4PaSs and @Freddrickk.

Pull-Request: #2022
Reviewed-by: Frédéric Vachon <fredvac@gmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agoMerge: iOS and text: fix UTF-8 support on iOS and improve doc on FFI related text...
Jean Privat [Wed, 20 Apr 2016 17:21:58 +0000 (13:21 -0400)]
Merge: iOS and text: fix UTF-8 support on iOS and improve doc on FFI related text services

This PR fix the support for UTF-8 on iOS by simply updating the encoding and use the correct number of bytes. This does not completely resolve #1945 as the error messages are still present and I suspect that the UTF-8 cleaning does not work, however I'll update the issue (or open a different one) to reflect that.

Intro the service `to_s_with_copy_and_length` which complements `to_s_with_copy` and `to_s_with_length` . The name is a mouthful, but using optional parameters was not desirable since this service will often be used from a foreign language.

Also improves the doc of the existing services to get a Nit `String` from a `NativeString`. The new doc is more detailed and oriented towards users of the FFI by putting emphasis on where the raw data resides and wether it is cleaned or not.

Also note the removal of return type declarations in method refinements which was not consistent with the introduction.

Pull-Request: #2021
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agoMerge: Interpreter FFI: fix running the interpreter FFI in the interpreter
Jean Privat [Wed, 20 Apr 2016 17:21:55 +0000 (13:21 -0400)]
Merge: Interpreter FFI: fix running the interpreter FFI in the interpreter

Let's start with a bit of context, the interpreter supports only the light FFI, a subset of the full FFI supported by the compiler. The interpreter uses an heuristic to guess which extern methods are supported. The problem of #2018, was in this heuristic. The heuristic states that if a parameter of an extern method is a standard Nit class and not an universal or an extern class, then that method probably uses the full FFI. However, sometimes this is false, like in the interpreter where instances of Nit standard classes are stored as pointer in the C code, still without using the full FFI.

To fix #2018, this PR intro a new annotation `light_ffi` to be used on extern methods wrongly detected as full FFI. It bypasses the heuristic and force the interpreter to compile and run the method. (or it tries to) This annotation should not be used otherwise, the heuristic is pretty good at detecting when a method is supported or not.

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

8 years agolib/core/bytes: add `Int::to_bytes` and `Bytes::to_i`
Jean Privat [Wed, 20 Apr 2016 17:20:33 +0000 (13:20 -0400)]
lib/core/bytes: add `Int::to_bytes` and `Bytes::to_i`

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

8 years agotests: add test for the interpreter interpreting the interpreter with its FFI
Alexis Laferrière [Mon, 18 Apr 2016 17:48:14 +0000 (13:48 -0400)]
tests: add test for the interpreter interpreting the interpreter with its FFI

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

8 years agolib/opts: report invalid integer passed to an OptionInt
Alexis Laferrière [Wed, 20 Apr 2016 11:34:29 +0000 (07:34 -0400)]
lib/opts: report invalid integer passed to an OptionInt

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

8 years agocontrib/inkscape_tools: fix noinit in redef warning
Alexandre Terrasa [Wed, 20 Apr 2016 06:35:06 +0000 (02:35 -0400)]
contrib/inkscape_tools: fix noinit in redef warning

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

8 years agouml: fix not escaped names
Alexandre Terrasa [Fri, 18 Dec 2015 05:18:12 +0000 (00:18 -0500)]
uml: fix not escaped names

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

8 years agovararg_routes: improve module documentation
Alexandre Terrasa [Wed, 20 Apr 2016 04:54:35 +0000 (00:54 -0400)]
vararg_routes: improve module documentation

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

8 years agonitcorn: remove warnings from reactor.nit
Alexandre Terrasa [Wed, 20 Apr 2016 04:54:04 +0000 (00:54 -0400)]
nitcorn: remove warnings from reactor.nit

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

8 years agonitcorn: fix path resolution for vararg routes
Alexandre Terrasa [Wed, 20 Apr 2016 04:53:47 +0000 (00:53 -0400)]
nitcorn: fix path resolution for vararg routes

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

8 years agolib/core: fix `Text::is_int`
Alexis Laferrière [Tue, 19 Apr 2016 17:44:06 +0000 (13:44 -0400)]
lib/core: fix `Text::is_int`

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

8 years agolib/cocoa: reading text from NSData should copy it to Nit memory
Alexis Laferrière [Fri, 15 Apr 2016 21:33:50 +0000 (17:33 -0400)]
lib/cocoa: reading text from NSData should copy it to Nit memory

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

8 years agolib/cocoa: fix to_nsstring to use UTF-8 encoding
Alexis Laferrière [Fri, 15 Apr 2016 21:06:24 +0000 (17:06 -0400)]
lib/cocoa: fix to_nsstring to use UTF-8 encoding

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

8 years agolib/core: remove duplicates and improve doc of `NativeString` related services
Alexis Laferrière [Mon, 18 Apr 2016 19:01:32 +0000 (15:01 -0400)]
lib/core: remove duplicates and improve doc of `NativeString` related services

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

8 years agolib/core: intro to_s_with_copy_and_length
Alexis Laferrière [Fri, 15 Apr 2016 22:01:35 +0000 (18:01 -0400)]
lib/core: intro to_s_with_copy_and_length

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

8 years agointerpreter: use light_ffi to force support for the `instance` extern methods
Alexis Laferrière [Mon, 18 Apr 2016 17:23:36 +0000 (13:23 -0400)]
interpreter: use light_ffi to force support for the `instance` extern methods

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

8 years agointerpreter: the annotation light_ffi identifies a method as light FFI only
Alexis Laferrière [Mon, 18 Apr 2016 17:23:01 +0000 (13:23 -0400)]
interpreter: the annotation light_ffi identifies a method as light FFI only

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

8 years agoMerge: Split catalog into a lib and a program
Jean Privat [Mon, 18 Apr 2016 12:51:54 +0000 (08:51 -0400)]
Merge: Split catalog into a lib and a program

As requested by @Morriar, the nitcatalog tool is now splited into a lib and a program.

Pull-Request: #2017
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

8 years agoMerge: iOS: support apps with multiple windows, and a better ListLayout
Jean Privat [Mon, 18 Apr 2016 12:51:53 +0000 (08:51 -0400)]
Merge: iOS: support apps with multiple windows, and a better ListLayout

Support multiple windows on iOS by using a UINavigationController as the root controller which shows the navigation bar at the top of the screen. The navigation bar shows the "Back" button automatically when switching windows. It has room for a title, which can be set manually. This is not ideal as pure portable apps don't define a title leaving the bar mostly empty. This could be fixed either by always asking for a title or by using the app names a default title.

Rewrite the implementation of the ListLayout using a UIStackView in a UIScrollView. This implementation is easier to adapt to different content, and it much more simple than the previous one which used a UITableView. The table view implementation has been kept as a different iOS specific control, but it may be removed in the future.

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

8 years agoMerge: app.nit services to set the size and alignment of labels
Jean Privat [Mon, 18 Apr 2016 12:51:51 +0000 (08:51 -0400)]
Merge: app.nit services to set the size and alignment of labels

Intro services to customize the size and alignment of text views. Only labels are supported on all platforms but Android also supports customizing text buttons. The behaviour on each platform varies a bit according to the available features. The goal is always to have the behaviour that is more natural on the platform instead of having the same exact look on each platform. Sticking to the recommended values should produce more consistent results, but using other values can create interesting effects.

For example, on Android and Linux, the text size is locked to a small/medium/large, but on iOS the size can be set to any variations relative to the default font size. On all platforms, 0.5 should result in a small font, 1.0 the default/medium size and 1.5 the large size. On iOS, other values will result in different text sizes.

I've used the same logic as `Text::justify` to set the alignment with a single float parameter.

Pull-Request: #2015
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

8 years agonitcatalog: add a new class Person
Jean Privat [Mon, 18 Apr 2016 00:53:14 +0000 (20:53 -0400)]
nitcatalog: add a new class Person

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

8 years agonitc: split nitcatalog into a lib and a program
Jean Privat [Sun, 17 Apr 2016 01:49:14 +0000 (21:49 -0400)]
nitc: split nitcatalog into a lib and a program

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

8 years agolib/ios: implement `Label::size= & align=`
Alexis Laferrière [Sat, 2 Apr 2016 21:54:44 +0000 (17:54 -0400)]
lib/ios: implement `Label::size= & align=`

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

8 years agolib/ios: support multiple windows using a UINavigationController
Alexis Laferrière [Mon, 14 Mar 2016 20:53:06 +0000 (16:53 -0400)]
lib/ios: support multiple windows using a UINavigationController

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

8 years agolib/ios: ListLayout use a UIStackView inside a UIScrollView
Alexis Laferrière [Fri, 15 Apr 2016 15:23:57 +0000 (11:23 -0400)]
lib/ios: ListLayout use a UIStackView inside a UIScrollView

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

8 years agolib/ios: use simple init constructor in Objective-C when possible
Alexis Laferrière [Thu, 14 Apr 2016 18:44:33 +0000 (14:44 -0400)]
lib/ios: use simple init constructor in Objective-C when possible

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

8 years agolib/ios: do not crash when removing a non-View control
Alexis Laferrière [Fri, 8 Apr 2016 18:57:51 +0000 (14:57 -0400)]
lib/ios: do not crash when removing a non-View control

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

8 years agonitc iOS: use ???? as bundle signature (now we can)
Alexis Laferrière [Mon, 14 Mar 2016 20:52:58 +0000 (16:52 -0400)]
nitc iOS: use ???? as bundle signature (now we can)

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

8 years agolib/linux: implement `Label::size= & align=`
Alexis Laferrière [Sat, 2 Apr 2016 17:27:08 +0000 (13:27 -0400)]
lib/linux: implement `Label::size= & align=`

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

8 years agolib/android: implement `TextView::size= & align=` and replace `text_size`
Alexis Laferrière [Sat, 2 Apr 2016 22:06:38 +0000 (18:06 -0400)]
lib/android: implement `TextView::size= & align=` and replace `text_size`

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

8 years agolib/app: intro `TextView::size= & align=`
Alexis Laferrière [Wed, 25 Nov 2015 21:29:58 +0000 (16:29 -0500)]
lib/app: intro `TextView::size= & align=`

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

8 years agolib/gtk: intro `GtkLabel::justify` and the `set_markup` service
Alexis Laferrière [Fri, 15 Apr 2016 14:26:40 +0000 (10:26 -0400)]
lib/gtk: intro `GtkLabel::justify` and the `set_markup`  service

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

8 years agolib/gtk: fix uncallable / unimplemented alignment and padding services
Alexis Laferrière [Sat, 2 Apr 2016 17:26:43 +0000 (13:26 -0400)]
lib/gtk: fix uncallable / unimplemented alignment and padding services

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

8 years agoMerge: Introducing the do ... catch ... end structure
Jean Privat [Thu, 14 Apr 2016 01:03:06 +0000 (21:03 -0400)]
Merge: Introducing the do ... catch ... end structure

This PR is a first step in trying to handle exceptions in Nit, replacing the behaviour of `abort` if it happens within a do ... catch ... end.

In the compiler, setjmp() et longjmp() are used to jump directly from the `abort` to the nearest `catch` bloc.

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

8 years agoMerge: Benitlux & sqlite3: fix closing SQLite statements and malformed superstring
Jean Privat [Thu, 14 Apr 2016 01:03:03 +0000 (21:03 -0400)]
Merge: Benitlux & sqlite3: fix closing SQLite statements and malformed superstring

Fix statements that were left open and did not remove the lock on the database. It now relies on iterators to close the statement after the end of the loop. This requires to actually complete the loop and not return before it is complete. A shortcut is to use `statement.iterator.to_a` when the result is expected to be short, like with a single row.

Note that I did not use `with` because it has the same problem with a `return` skipping the call to `finish`. Neither did I use `Finalizable` because it is invoked by the GC which may be much later.

Also fix one malformed superstring and improve the style of another one.

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

8 years agotests: introducing some tests for the catch
BlackMinou [Sat, 9 Apr 2016 01:24:10 +0000 (21:24 -0400)]
tests: introducing some tests for the catch

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

8 years agoCompiler: using longjumps for the catch blocs
BlackMinou [Sat, 9 Apr 2016 00:23:09 +0000 (20:23 -0400)]
Compiler: using longjumps for the catch blocs

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

8 years agoInterpreter: using catch to modify abort behaviour
BlackMinou [Sat, 9 Apr 2016 00:22:21 +0000 (20:22 -0400)]
Interpreter: using catch to modify abort behaviour

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

8 years agoScope & Typing: visits the catch part of a do ... catch ... end
BlackMinou [Sat, 9 Apr 2016 00:20:43 +0000 (20:20 -0400)]
Scope & Typing: visits the catch part of a do ... catch ... end

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

8 years agoFlow: managing the flow context for a do ... catch ... end
BlackMinou [Sat, 9 Apr 2016 00:19:43 +0000 (20:19 -0400)]
Flow: managing the flow context for a do ... catch ... end

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

8 years agoParser: Modifications due to the introduction of catch
BlackMinou [Sat, 9 Apr 2016 00:18:27 +0000 (20:18 -0400)]
Parser: Modifications due to the introduction of catch

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

8 years agoGrammar: Adding an optionnal catch bloc to a do end
BlackMinou [Sat, 9 Apr 2016 00:17:47 +0000 (20:17 -0400)]
Grammar: Adding an optionnal catch bloc to a do end

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

8 years agoAdded services to NativeString and Byte
Lucas Bajolet [Mon, 11 Apr 2016 17:22:09 +0000 (13:22 -0400)]
Added services to NativeString and Byte

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agolib/sqlite3: improve doc and customization of the iterator closing statements
Alexis Laferrière [Mon, 11 Apr 2016 16:10:25 +0000 (12:10 -0400)]
lib/sqlite3: improve doc and customization of the iterator closing statements

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

8 years agoMerge: Unify escaping
Jean Privat [Sat, 9 Apr 2016 13:58:02 +0000 (09:58 -0400)]
Merge: Unify escaping

For some historical reasons, the `return` was managed slightly differently from `break` and `continue`.

This PR unify the whole thing thus simplify how the escaping mechanism is handled by the interpreted. By the way this also fixes #2008 (that is caused by an unhandled `return` specific case)

This will also help the implementation of correct escaping and `finally` in the compiler.

Pull-Request: #2010
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

8 years agoMerge: Tnitter app: fix list layout on GNU/Linux with GTK+
Jean Privat [Sat, 9 Apr 2016 13:57:59 +0000 (09:57 -0400)]
Merge: Tnitter app: fix list layout on GNU/Linux with GTK+

Update GNU/Linux implementation of `ListLayout` to follow the specification of `GtkListBox` which should only have children of type `GtkListBoxRow`. This was an issue in Tnitter where removing children from the `GtkListBox` was broken.

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

8 years agoMerge: More byte digests
Jean Privat [Sat, 9 Apr 2016 13:57:57 +0000 (09:57 -0400)]
Merge: More byte digests

Improve and some back-and-forth transformations between Byte and Text.

~~~nit
var b = "abcd".to_bytes
assert b.chexdigest == "\\x61\\x62\\x63\\x64"
assert b.chexdigest.unescape_to_bytes == b
assert b.binarydigest == "01100001011000100110001101100100"
assert b.binarydigest.binarydigest_to_bytes == b

assert "1".binarydigest_to_bytes.hexdigest == "01"
assert "1 0 1".binarydigest_to_bytes.hexdigest == "05"
assert "7".hexdigest_to_bytes.hexdigest == "07"
assert "a B cd \\xe".hexdigest_to_bytes.hexdigest == "0ABCDE"
~~~

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

8 years agocore/bytes: make Text::hexdigest_to_bytes more permissive
Jean Privat [Sat, 9 Apr 2016 13:56:49 +0000 (09:56 -0400)]
core/bytes: make Text::hexdigest_to_bytes more permissive

It now accepts a odd number of digit and garbage (eg. whitespaces) in
the strings

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

8 years agotests: add base_with_return.res
Jean Privat [Fri, 8 Apr 2016 19:17:46 +0000 (15:17 -0400)]
tests: add base_with_return.res

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

8 years agotests: update line number in test_new_native.nit
Alexis Laferrière [Fri, 8 Apr 2016 16:57:39 +0000 (12:57 -0400)]
tests: update line number in test_new_native.nit

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

8 years agonitc/niti: unify returnmark and escapemark
Jean Privat [Fri, 8 Apr 2016 15:49:23 +0000 (11:49 -0400)]
nitc/niti: unify returnmark and escapemark

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

8 years agonitc/scope: attach AReturnExpr to an escape mark of the whole propdef
Jean Privat [Fri, 8 Apr 2016 15:46:47 +0000 (11:46 -0400)]
nitc/scope: attach AReturnExpr to an escape mark of the whole propdef

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

8 years agonitc/parser: Make `AReturnExpr` an AEscapeExpr
Jean Privat [Fri, 8 Apr 2016 15:45:15 +0000 (11:45 -0400)]
nitc/parser: Make `AReturnExpr` an AEscapeExpr

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

8 years agocontrib/benitlux: fix superstring in benitlux_social
Alexis Laferrière [Wed, 6 Apr 2016 15:40:54 +0000 (11:40 -0400)]
contrib/benitlux: fix superstring in benitlux_social

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

8 years agocontrib/benitlux: let the iterators close the sqlite statements
Alexis Laferrière [Fri, 8 Apr 2016 15:08:41 +0000 (11:08 -0400)]
contrib/benitlux: let the iterators close the sqlite statements

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

8 years agolib/core: fix `Iterator::to_a` not calling `finish`
Alexis Laferrière [Fri, 8 Apr 2016 15:20:17 +0000 (11:20 -0400)]
lib/core: fix `Iterator::to_a` not calling `finish`

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

8 years agolib/sqlite3: protect close statements
Alexis Laferrière [Fri, 8 Apr 2016 12:50:31 +0000 (08:50 -0400)]
lib/sqlite3: protect close statements

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

8 years agolib/sqlite3: fix closing a statement after iterating
Alexis Laferrière [Fri, 8 Apr 2016 11:47:31 +0000 (07:47 -0400)]
lib/sqlite3: fix closing a statement after iterating

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

8 years agocontrib/tnitter: use the new `clear` for a cleaner behavior
Alexis Laferrière [Thu, 7 Apr 2016 17:45:22 +0000 (13:45 -0400)]
contrib/tnitter: use the new `clear` for a cleaner behavior

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

8 years agolib/linux: fix ListBox that should contain only ListBoxRows
Alexis Laferrière [Thu, 7 Apr 2016 17:43:34 +0000 (13:43 -0400)]
lib/linux: fix ListBox that should contain only ListBoxRows

Reported-by: Abdelkarim Belkhir <abdelkarim.belkhir.exalger@viacesi.fr>
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

8 years agolib/gtk: GtkListBoxRow is a GtkBin
Alexis Laferrière [Thu, 7 Apr 2016 17:43:01 +0000 (13:43 -0400)]
lib/gtk: GtkListBoxRow is a GtkBin

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

8 years agolib/app: intro `CompositeControl::clear`
Alexis Laferrière [Thu, 7 Apr 2016 16:37:36 +0000 (12:37 -0400)]
lib/app: intro `CompositeControl::clear`

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

8 years agocore/bytes: add `Bytes::binarydigest` and `Text::binarydigest_to_bytes`
Jean Privat [Thu, 7 Apr 2016 13:31:07 +0000 (09:31 -0400)]
core/bytes: add `Bytes::binarydigest` and `Text::binarydigest_to_bytes`

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

8 years agocore/bytes: add `Byte::chexdigest`
Jean Privat [Thu, 7 Apr 2016 13:28:46 +0000 (09:28 -0400)]
core/bytes: add `Byte::chexdigest`

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