From fd07b17bdfd8ef60bd6d6bcd1de88fe44fe3c8c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 14 Oct 2016 09:29:38 -0400 Subject: [PATCH] nitrestful: detect the async keyword MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- src/nitrestful.nit | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/nitrestful.nit b/src/nitrestful.nit index 2b118a3..68e8258 100644 --- a/src/nitrestful.nit +++ b/src/nitrestful.nit @@ -37,6 +37,12 @@ private class RestfulPhase return end + var mpropdef = node.mpropdef + if mpropdef == null then return + var mproperty = mpropdef.mproperty + var mclassdef = mpropdef.mclassdef + var mmodule = mclassdef.mmodule + var http_resources = new Array[String] var http_methods = new Array[String] for arg in nat.n_args do @@ -48,6 +54,8 @@ private class RestfulPhase else if arg isa ATypeExpr and not id.chars.has("[") then # Class id -> HTTP method http_methods.add id + else if id == "async" then + mproperty.restful_async = true else toolcontext.error(nat.location, "Syntax Error: `restful` expects String literals or ids as arguments.") @@ -55,13 +63,6 @@ private class RestfulPhase end end - var mpropdef = node.mpropdef - if mpropdef == null then return - - var mproperty = mpropdef.mproperty - var mclassdef = mpropdef.mclassdef - var mmodule = mclassdef.mmodule - # Test subclass of `RestfulAction` var sup_class_name = "RestfulAction" var sup_class = toolcontext.modelbuilder.try_get_mclass_by_name( @@ -97,6 +98,9 @@ redef class MMethod # Associated resources within an action, e.g. `foo` in `http://localhost/foo?arg=bar` private var restful_resources: Array[String] = [name] is lazy + + # Is this a `restful` method to be executed asynchronously + private var restful_async = false end redef class ToolContext -- 1.7.9.5