Jean Privat [Tue, 6 Jun 2017 15:44:08 +0000 (11:44 -0400)]
Merge: popcorn: some useful services for JSON related REST API
This PR introduces a way to validate and deserialize requests bodies with some shortcuts.
I'm not a big fan of the `new_body_object` but I don't see how to do this elegantly...
~~~nit
class MyJsonHandler
super Handler
# Validator used do validate the body
redef var validator = new MyFormValidator
# Define the kind of objects expected by the deserialization process
redef type BODY: MyForm
# Instanciate the object from a deserializer
redef fun new_body_object(d) do return new MyForm.from_deserializer(d)
redef fun post(req, res) do
var post = validate_body(req, res)
if post == null then return # Validation error: let popcorn return a HTTP 400
var form = deserialize_body(req, res)
if form == null then return # Deserialization error: let popcorn return a HTTP 400
# TODO do something with the input
print form.name
end
end
class MyForm
serialize
var name: String
end
class MyFormValidator
super ObjectValidator
init do
add new StringField("name", min_size=1, max_size=255)
end
end
~~~
Also, I moved json related services to this module and updated the clients.
Pull-Request: #2465
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 6 Jun 2017 15:39:54 +0000 (11:39 -0400)]
Merge: model: Remove truthful conditions
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2442
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean Privat [Tue, 6 Jun 2017 15:37:33 +0000 (11:37 -0400)]
Merge: Actors upgrade and fixes
`BlockingQueue` and `ReverseBlockingQueue` classes have been removed from `lib/actors` and are now in `lib/pthreads/concurrent_collections` because it's a better fit for them.
Also, since the implementation of `BlockingQueue` was too coupled with actors, the actor-specific implementation was kept in `lib/actors` and renamed as `Mailbox`.
`ReverseBlockingQueue` is a fun name and could be useful for some specific cases (as it was used in `lib/actors` or for synchronization on a list of dynamic tasks for example), but was too heavy for it's purpose in the `lib/actors` module. It's been replaced with a `SynchronizedCounter`. The `wait` method of this counter is blocking until the counter value equals 0.
There was multiple synchronization problems with the actor library :
* The creation of `async`, aka the proxy wasn't synchronized, which means we could create multiple instances of an actor if multiple threads called `async` on an object simultaneously
* Due to the asynchronous start of an actor (a new on a Nit Thread can return before the actual underlying C pthread started running), there was some cases where the mecanism used to wait for every actors to be idle before exiting a program was broken.
This PR adresses theses 2 bugs. The first one is just adding a mutex used for the creation of the `async` object.
The second one was adressed by moving the logic dealing with the idle state of an actor directly into his mailbox.
This PR also makes it possible to redefine an actor class. `lib/actors/agent_simulation` provides an example of this feature:
* `agent_simulation.nit` defines a simple api to which defines a Multi-agent simulation. The `ClockWorker` is in charge of the simulation and executes every steps, waiting for one to be finished before launching the other. the list of `Agent` it manages are all the agents of the simulation, which are actors too.
* `simple_simulation.nit` redefine the `Agent` class to add specific services for a specific simulation. Here, each agent knows every other one in the simluation and greets them, wait to be greeted back by everyone, then signals the clock that it finished the step.
This feature can be useful, but hasn't been fully tested yet. Furthermore, the Nit actor model still doesn't support subclassing an actor, which could also be really useful.
Well, that's pretty much it, enjoy reading :p
Pull-Request: #2425
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Alexandre Terrasa [Fri, 2 Jun 2017 14:32:55 +0000 (10:32 -0400)]
lib/popcorn: import pop_json when needed
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 25 May 2017 23:32:59 +0000 (19:32 -0400)]
lib/popcorn: move json related services to `pop_json`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 25 May 2017 23:32:19 +0000 (19:32 -0400)]
lib/popcorn: add useful services for JSON REST handlers
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
BlackMinou [Mon, 8 May 2017 17:59:28 +0000 (13:59 -0400)]
Introducing agent simulation: an actor redefinition example
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>
BlackMinou [Mon, 8 May 2017 17:52:15 +0000 (13:52 -0400)]
Generate appropriate code for actors redefinitions
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>
BlackMinou [Mon, 8 May 2017 17:50:02 +0000 (13:50 -0400)]
use `SynchronizedCounter` in chameneos-redux
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>
BlackMinou [Mon, 8 May 2017 02:06:54 +0000 (22:06 -0400)]
Fix synchronizations problem to better track active actors
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>
BlackMinou [Mon, 8 May 2017 02:03:39 +0000 (22:03 -0400)]
Move `BlockingQueue` and `ReverseBlockingQueue` to `concurrent_collection`
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>
Jean Privat [Mon, 29 May 2017 15:07:16 +0000 (11:07 -0400)]
Merge: geometry: implement 3D `dist` and improve API
The main change in this PR is the reimplementation of `Point::dist` and `dist2` to support 3D points, including comparing 2D and 3D points. The double dispatch logic is a bit complex but it works with any receiver.
This PR also tweaks existing services to improve the API and doc:
* Make all attributes of `Point` optional for gradual creation/space allocation. In practice, points are often created with a default value, as a kind of buffer, or with the Z axis at 0.
* Rework `BoxedArray` as a subclass of `Array` to inherit its services (incl. `remove`) while using less code.
* Move the custom `to_s` from the concrete boxes to the interfaces as it is very useful when debugging.
Pull-Request: #2462
Jean Privat [Mon, 29 May 2017 15:07:15 +0000 (11:07 -0400)]
Merge: lib/popcorn: introduce `AppConfig::app_hostname`
Introduce `app_hostname` in popcorn AppConfig.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Pull-Request: #2464
Jean Privat [Mon, 29 May 2017 15:07:14 +0000 (11:07 -0400)]
Merge: gamnit & sdl2: implement app::audio using SDL2 mixer
Intro a decent implementation of `app::audio` for desktop computers using SDL2 mixer. It supports WAV, MP3, OGG and more. The underlying SDL2 mixer bindings are minimal, they offer only the required features, more can be added as needed.
Clients of the gamnit framework will need to `apt-get install libsdl2-mixer-dev`.
Pull-Request: #2466
Alexis Laferrière [Sat, 20 May 2017 17:45:03 +0000 (10:45 -0700)]
geometry: implement `Point::dist` for 3D points
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Sat, 20 May 2017 17:44:03 +0000 (10:44 -0700)]
geometry: make `BoxedArray` a subclass of `Array`
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Thu, 18 May 2017 19:52:26 +0000 (12:52 -0700)]
geometry: make the attributes of points optional
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Thu, 18 May 2017 19:51:23 +0000 (12:51 -0700)]
geometry: move up custom `to_s` to the interfaces
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Thu, 25 May 2017 16:56:08 +0000 (12:56 -0400)]
gamnit: implement app::audio for desktop using SDL2 mixer
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Fri, 26 May 2017 00:02:42 +0000 (20:02 -0400)]
sdl2: intro minimal bindings to SDL2 mixer
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Thu, 25 May 2017 23:59:01 +0000 (19:59 -0400)]
audio: move some services between the abstraction and the Android layers
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexandre Terrasa [Thu, 25 May 2017 22:30:23 +0000 (18:30 -0400)]
lib/popcorn: introduce `AppConfig::app_hostname`
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Thu, 25 May 2017 14:55:23 +0000 (10:55 -0400)]
Merge: Popcorn templates
# Template rendering for popcorn
## Basic templates
Use TemplateString to render really basic templates that just need macro
replacements.
Example:
~~~nit
class TemplateStringHandler
super Handler
redef fun get(req, res) do
# Values to add in the template
var values = new HashMap[String, String]
values["USER"] = "Morriar"
values["MYSITE"] = "My super website"
# Render it with a shortcut
res.template_string("""
<h1>Hello %USER%!</h1>
<p>Welcome to %MYSITE%.</p>
""", values)
end
end
~~~
For larger templates, you can also use external files (makes your Nit code cleaner):
~~~nit
class TemplateFileHandler
super Handler
redef fun get(req, res) do
# Values to add in the template
var values = new HashMap[String, String]
values["USER"] = "Morriar"
values["MYSITE"] = "My super website"
# Render it from an external file
res.template_file("example_template.tpl", values)
end
end
~~~
## Using pug templates
Pug is a templating format provided by the external command `pug`.
For complex templates that need conditional or loop statements, pug can be a solution.
See the pug syntax here: https://pugjs.org/api/getting-started.html
~~~nit
class PugFileHandler
super Handler
redef fun get(req, res) do
# Values to add in the template
var json = new JsonObject
json["user"] = "Morriar"
json["mysite"] = "My super website"
# Render it from an external file
res.pug_file("example_template.pug", json)
end
end
~~~
Pull-Request: #2449
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 25 May 2017 14:55:22 +0000 (10:55 -0400)]
Merge: coloring: Only generate strictly positive IDs
This will allow to reserve negative IDs (including 0) for special purposes.
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2457
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 25 May 2017 14:55:21 +0000 (10:55 -0400)]
Merge: model: Do not assume enums to be final
An upcoming feature will destroy this assumption.
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2458
Jean Privat [Thu, 25 May 2017 14:55:20 +0000 (10:55 -0400)]
Merge: gamnit: intro support for Angel Code bitmap font
The BMFont format supports packed textures, varying advance per character and even kernings. It can be generated by a number of tools, including:
* BMFont, free software Windows app, http://www.angelcode.com/products/bmfont/
* Littera, a web app, http://kvazars.com/littera/
This PR also generalizes the `Font` and `TextSprites` concepts, previously limited to tile set bitmap fonts. And add a new shortcut service to the excellent DOM parser used to parse the XML description.
The result is much nicer than what was previously available, you can see it in a preview of my latest project:
![screenshot from 2017-05-22 12-38-55](https://cloud.githubusercontent.com/assets/208057/
26353142/
eeeb29a6-3f8c-11e7-847d-
b5ccc8a93822.png)
The parsing method crash easily on malformatted font description file. However, since the description file should be generated, loaded at game start and not often modified, all expected crash errors should occur in dev only. Errors that can happen in production, like a truncated file or a misplaced file, should be detected by the basic sanity checks.
If an error occurs while loading a font, there is currently no automatic fallback and it will probably lead to an unusable game. It could be remedied by adding a default font, similar to the default material and mesh. It would be very useful, even at the beginning of any projects, but there is some technical limitations to implementing it as of now.
In the future, I plan on moving up more services from `TileSetFont` and add text alignment features. The `flat` module needs to be split in a group to include more services, including fonts.
Pull-Request: #2459
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Alexis Laferrière [Mon, 22 May 2017 18:12:42 +0000 (11:12 -0700)]
gamnit: intro BMFont parser and drawing services
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Mon, 22 May 2017 17:51:16 +0000 (10:51 -0700)]
gamnit: extract general Font from TileSetFont
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Sun, 21 May 2017 15:54:56 +0000 (08:54 -0700)]
dom: intro `XMLTag::attributes_to_map` mapping `XMLStringAttr` to their value
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean-Christophe Beaupré [Tue, 23 May 2017 16:10:19 +0000 (12:10 -0400)]
tests: Update error messages
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Tue, 23 May 2017 04:12:49 +0000 (00:12 -0400)]
model: Do not assume enums to be final
An upcoming feature will destroy this assumption.
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Tue, 23 May 2017 16:09:49 +0000 (12:09 -0400)]
tests: Do not rely on the implicit fixing of type bounds
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean Privat [Tue, 23 May 2017 15:24:00 +0000 (11:24 -0400)]
Merge: model: Fix minor documentation mistakes
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2451
Jean Privat [Tue, 23 May 2017 15:23:59 +0000 (11:23 -0400)]
Merge: nitvm: Factorize the loading of superclasses
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2452
Jean Privat [Tue, 23 May 2017 15:23:58 +0000 (11:23 -0400)]
Merge: parser_nodes: Fix documentation
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2453
Jean Privat [Tue, 23 May 2017 15:23:57 +0000 (11:23 -0400)]
Merge: rosettacode: Fix spelling mistakes
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2454
Jean Privat [Tue, 23 May 2017 15:23:56 +0000 (11:23 -0400)]
Merge: rapid_type_analysis: Fix a spelling mistake
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2455
Alexis Laferrière [Sun, 21 May 2017 15:54:21 +0000 (08:54 -0700)]
dom: return a more precise `Array[XMLTag]` as the doc already said
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean-Christophe Beaupré [Tue, 23 May 2017 04:13:38 +0000 (00:13 -0400)]
metrics_base: Do not rely on the implicit fixing of type bounds
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Tue, 9 May 2017 17:42:25 +0000 (13:42 -0400)]
opts: Do not rely on the implicit fixing of type bounds
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Sun, 21 May 2017 23:20:58 +0000 (19:20 -0400)]
coloring: Only generate strictly positive IDs
This will allow to reserve negative IDs (including 0) for special purposes.
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Sun, 21 May 2017 23:24:10 +0000 (19:24 -0400)]
coloring: Fix documentation formatting
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Thu, 9 Mar 2017 03:23:26 +0000 (22:23 -0500)]
rapid_type_analysis: Fix a spelling mistake
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Sat, 20 May 2017 23:06:39 +0000 (19:06 -0400)]
rosettacode: Fix spelling mistakes
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Fri, 19 May 2017 19:15:52 +0000 (15:15 -0400)]
parser_nodes: Fix documentation
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Thu, 18 May 2017 16:39:30 +0000 (12:39 -0400)]
model: Fix minor documentation mistakes
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean Privat [Thu, 18 May 2017 15:02:05 +0000 (11:02 -0400)]
Merge: Popcorn: clean tests
This PR does two things:
* clean the lib by moving all the tests to `tests/` directories, easier to see what is important, great visual improvement for the examples.
* use a lot of imagination to avoid the `class name X already used`. It mostly replaces Short&Cool names by LooooonnggggandAndBooooringNameForSoSimpleHandler. No more warnings when make checking.
Pull-Request: #2434
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Thu, 18 May 2017 15:02:03 +0000 (11:02 -0400)]
Merge: MultiHashMap: Provide the converse of `add_one`
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2446
Jean-Christophe Beaupré [Thu, 18 May 2017 04:33:20 +0000 (00:33 -0400)]
nitvm: Factorize the loading of superclasses
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Alexandre Terrasa [Tue, 16 May 2017 18:33:41 +0000 (14:33 -0400)]
lib/popcorn: add documentation for pop_templates
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 16 May 2017 18:33:25 +0000 (14:33 -0400)]
lib/popcorn: add pug rendering
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 16 May 2017 17:17:43 +0000 (13:17 -0400)]
lib/popcorn: introduce basic templates
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 17 May 2017 13:53:42 +0000 (09:53 -0400)]
Merge: gamnit: add documentation and standardize the API
Improve the documentation for the central services of gamnit, mainly for entities visible from gamnit.org. Also, to improve the API, remove the `Gamnit` from some class name and move a few named constuctors to factories or their own class.
Pull-Request: #2422
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 17 May 2017 13:53:41 +0000 (09:53 -0400)]
Merge: rosettacode: Add integer_overflow rosetta code exemple
Signed-off-by: PatrickBlanchette <PatrickBlanchette@users.noreply.github.com>
Pull-Request: #2431
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 17 May 2017 13:53:39 +0000 (09:53 -0400)]
Merge: Popcorn: more validators
Add two more validators:
* URLField that ensures a field contains a valid URL (you want to redefine that regexp).
* UniqField stubs for uniq emails, logins, ids validation.
How to validate uniq field:
~~~nit
class UniqEmailField
super UniqField
var users: UsersRepository
redef fun check_unicity(v, field, val) do
var user = users.find_by_email(val)
if user != null then
v.validation.add_error(field, "Email `{val}` already used")
return false
end
return true
end
end
~~~
Pull-Request: #2435
Jean Privat [Wed, 17 May 2017 13:53:38 +0000 (09:53 -0400)]
Merge: lib/popcorn: introduce tasks
This PR is based on #2436
## Popcorn threaded tasks
Tasks allow you to execute code in another thread than the app listening loop.
Useful when you want to run some tasks periodically.
Let's say you want to purge the `downloads/` directory of your app every hour:
~~~nit
class PurgeTask
super PopTask
var dir: String
redef fun main do
loop
dir.rmdir
3600.sleep
end
end
end
var app = new App
# Register a new task
app.register_task(new PurgeTask("downloads/"))
# Add your handlers
# app.use('/', new MyHandler)
# Run the tasks
app.run_tasks
# Start the app
app.listen("0.0.0.0", 3000)
~~~
Pull-Request: #2437
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 17 May 2017 13:53:37 +0000 (09:53 -0400)]
Merge: model: Specify `MClassDef`s’ order once
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2441
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 17 May 2017 13:53:35 +0000 (09:53 -0400)]
Merge: core: fix dynamic error on the input type in `Text::replace`
The previous use of the virtual `SELFTYPE` on a parameter of `replace` was too restrictive and caused a dynamic crash when replacing something in a `String` by a `FlatBuffer` (for example). This PR uses the more general `Text` as the parameter type, which is already supported by the existing implementation.
The minimal case is not the most useful as doc but I've added it as a unit test anyway:
~~~
var t: Text = "hello"
assert t.replace("hello", new FlatBuffer) == ""
~~~
Pull-Request: #2447
Jean Privat [Wed, 17 May 2017 13:53:34 +0000 (09:53 -0400)]
Merge: lib/core/stream: fix typo in doc
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Pull-Request: #2448
Alexandre Terrasa [Wed, 17 May 2017 13:49:13 +0000 (09:49 -0400)]
lib/popcorn: fix file inclusion for Jenkins tests
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Wed, 17 May 2017 13:49:33 +0000 (09:49 -0400)]
lib/popcorn: add `test_path` shortcut in pop_tests
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 May 2017 23:20:24 +0000 (19:20 -0400)]
lib/popcorn: lot of class renaming in examples and tests to avoid the `class X already defined in...` warning
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 May 2017 23:07:37 +0000 (19:07 -0400)]
lib/popcorn: move examples tests to nice and tidy tests/ directories.
So the user/reader directly see the important files.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Mon, 15 May 2017 22:58:51 +0000 (18:58 -0400)]
lib/popcorn: move lib tests to a nice and tidy tests/ directory
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 16 May 2017 20:41:50 +0000 (16:41 -0400)]
lib/popcorn: fix serialization of validation errors
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 16 May 2017 20:41:35 +0000 (16:41 -0400)]
lib/popcorn: introduce UniqueField stub validator
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 May 2017 23:08:36 +0000 (19:08 -0400)]
lib/popcorn: introduce URLField validator
Someone is going to be picky on that re...
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Tue, 16 May 2017 18:13:46 +0000 (14:13 -0400)]
lib/core/stram: fix typo in doc
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexis Laferrière [Sun, 7 May 2017 03:41:48 +0000 (23:41 -0400)]
gamnit and related: improve doc
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexandre Terrasa [Fri, 12 May 2017 00:44:19 +0000 (20:44 -0400)]
lib/popcorn: introduce popcorn tasks
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexis Laferrière [Tue, 16 May 2017 15:38:28 +0000 (11:38 -0400)]
core/text: fix input type in `replace`
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean Privat [Tue, 16 May 2017 13:28:22 +0000 (09:28 -0400)]
Merge: nitcorn: fix HttpRequest::int_arg
Before this commit, sending `?n=9.5` to a nitcorn application using `int_arg`
caused the app to crash (see the following to_i).
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Pull-Request: #2414
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean Privat [Tue, 16 May 2017 13:28:17 +0000 (09:28 -0400)]
Merge: Custom serializer
This is an old attempt to add the possibility to have a custom serializer. The idea is that a same set of objects can be serialized in different ways if different serializers are used.
Most of what is needed to do that is already present; the main contribution of this PR is the example that tries to propose a way to do that. The example focuses on 3 simples needs:
* inject a phantom attribute.
when serializing, the custom serializer inject new attributes.
* hide a normally serialized attribute.
when serializing, the custom serializer hides some specific attributes.
* replace a full business object.
instead of serializing an attribute, the custom serializer use a different representation
Pull-Request: #2426
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean Privat [Tue, 16 May 2017 13:28:15 +0000 (09:28 -0400)]
Merge: lib/core/time: more time related services
Three things here:
* Introduce `Int::sleep` because of my hatred for `1.0.sleep`
* Introduce `get_microtime` because timestamp are better in microseconds
* Introduce `get_millitime` because sometimes, god forbid, we have to deal with Javascript
Also, I'm using `sys/time`, pretty sure I'm doing something that should not be in the core library.
Pull-Request: #2436
Jean Privat [Tue, 16 May 2017 13:28:13 +0000 (09:28 -0400)]
Merge: lib/popcorn: replace json_error method by something more useful
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Pull-Request: #2438
Jean Privat [Tue, 16 May 2017 13:28:10 +0000 (09:28 -0400)]
Merge: lib/json: remove Jsonable and replace it by Serializable
Remove the now useless Jsonable class.
Let's see if something is broken.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Pull-Request: #2439
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 16 May 2017 13:28:07 +0000 (09:28 -0400)]
Merge: Sha1 is digest
Change receiver of Sha1 methods from String to Text since no service was specific to immutable instances, and add a sha1_is_digest method to Text, to check whether an instance matches the signature of a SHA-1 digest or not.
Pull-Request: #2440
Jean Privat [Tue, 16 May 2017 13:28:00 +0000 (09:28 -0400)]
Merge: separate_compiler: Fix a spelling mistake in a comment
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2443
Jean Privat [Tue, 16 May 2017 13:27:58 +0000 (09:27 -0400)]
Merge: Makefile: Fix glob patterns
Forgot the call to `$(wildcard)`.
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Pull-Request: #2444
Jean-Christophe Beaupré [Wed, 10 Aug 2016 15:44:30 +0000 (11:44 -0400)]
MultiHashMap: Provide the converse of `add_one`
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Wed, 10 Aug 2016 15:43:48 +0000 (11:43 -0400)]
MultiHashMap: Add a test for `add_one`
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Alexandre Terrasa [Mon, 15 May 2017 23:16:11 +0000 (19:16 -0400)]
examples: rename Int::sleep from FFI examples to Int::sleep_seconds
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean-Christophe Beaupré [Mon, 15 May 2017 14:57:16 +0000 (10:57 -0400)]
model: Specify `MClassDef`s’ order once
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Mon, 15 May 2017 14:57:03 +0000 (10:57 -0400)]
model: Register sorters as private attributes of `MModule`
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
PatrickBlanchette [Tue, 9 May 2017 18:04:01 +0000 (14:04 -0400)]
rosettacode: Add integer_overflow rosetta code exemple
Signed-off-by: PatrickBlanchette <PatrickBlanchette@users.noreply.github.com>
Jean-Christophe Beaupré [Sun, 14 May 2017 22:26:24 +0000 (18:26 -0400)]
Makefile: Fix glob patterns
Forgot the call to `$(wildcard)`.
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Sun, 14 May 2017 16:46:43 +0000 (12:46 -0400)]
separate_compiler: Fix a spelling mistake in a comment
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Jean-Christophe Beaupré [Sat, 23 Jul 2016 22:30:07 +0000 (18:30 -0400)]
model: Remove truthful conditions
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Lucas Bajolet [Sat, 13 May 2017 17:15:20 +0000 (13:15 -0400)]
lib/sha1: add Text::is_sha1_digest
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Lucas Bajolet [Sat, 13 May 2017 17:16:21 +0000 (13:16 -0400)]
lib/sha1: replace String by Text for sha1 methods
Since SHA-1 methods might be applied on any kind of Text entity,
we replace the receiver class by Text.
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Alexandre Terrasa [Fri, 12 May 2017 05:29:32 +0000 (01:29 -0400)]
tests: update test for nitserial
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 12 May 2017 05:29:21 +0000 (01:29 -0400)]
lib/json: remove Jsonable and replace it by Serializable
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 12 May 2017 01:47:58 +0000 (21:47 -0400)]
lib/popcorn: replace json_error method by something more useful
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 12 May 2017 00:08:19 +0000 (20:08 -0400)]
lib/core/time: also sleep on integers
It always bothered me to write `1.0.sleep`...
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Fri, 12 May 2017 00:07:33 +0000 (20:07 -0400)]
lib/core/time: introduce get_millitime and get_microtime
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Thu, 11 May 2017 22:24:59 +0000 (18:24 -0400)]
nitcorn: fix HttpRequest::int_arg
Before this commit, sending `?n=9.5` to a nitcorn application using `int_arg`
caused the app to crash (see the following to_i).
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 10 May 2017 13:28:41 +0000 (09:28 -0400)]
Merge: nitc: add option --run to execute after a successful compilation.
When the naive interpreter is tooo slooooow but you are too lazy to run the binary yourself.
Pull-Request: #2432
Jean Privat [Wed, 10 May 2017 13:20:53 +0000 (09:20 -0400)]
Merge: Nitweb: api for code highlighter and nitpicker
Only the low-level JSON-REST API is provided. Someone should have to do the rendering.
ping @Morriar
Pull-Request: #2198
Jean Privat [Wed, 10 May 2017 13:20:50 +0000 (09:20 -0400)]
Merge: gamnit: fix nitunit compatibility
Unit tests in the gamnit module were not executed because Sys::setup exited right away when detecting NIT_TESTING. It affected all gamnit games. This PR check is a platform is bound at the beginning of `Sys::main`, allowing unit tests to run (whether they redef `main` or not).
The check is made possible by the new `bound_platform` which tells what platform is currently bound. This value can be useful in some other cases.
This is an alternative to #2394.
Pull-Request: #2420
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 10 May 2017 13:20:49 +0000 (09:20 -0400)]
Merge: core & gamnit: basic support for the characters nbsp, pld and plu
Detect non-breaking spaces in `is_whitespace`, and extend `TextSprites` to accept partial line skips, for sub/superscripts or simple half line skip.
Pull-Request: #2427
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>