Przeglądaj źródła

ncd: modules: call: allow resolving variables inside the called process, using the new
NCDModuleProcess interface for resolving variables

ambrop7 14 lat temu
rodzic
commit
0b0254c48b
1 zmienionych plików z 24 dodań i 2 usunięć
  1. 24 2
      ncd/modules/call.c

+ 24 - 2
ncd/modules/call.c

@@ -22,11 +22,15 @@
  * @section DESCRIPTION
  * @section DESCRIPTION
  * 
  * 
  * Synopsis: call(string template_name, list args)
  * Synopsis: call(string template_name, list args)
+ * 
  * Description:
  * Description:
  *   Module which allows using a single statement to represent multiple statements
  *   Module which allows using a single statement to represent multiple statements
  *   in a process template, allowing reuse of repetitive code.
  *   in a process template, allowing reuse of repetitive code.
  * 
  * 
- *   Behavior in detail:
+ * Variables:
+ *   Exposes variables as seen from the end of the called process template.
+ * 
+ * Behavior in detail:
  *   - On initialization, creates a new process from the template named
  *   - On initialization, creates a new process from the template named
  *     template_name, with arguments args.
  *     template_name, with arguments args.
  *   - When all the statements in the created process go UP, transitions UP.
  *   - When all the statements in the created process go UP, transitions UP.
@@ -182,12 +186,30 @@ static void func_clean (void *vo)
     o->state = STATE_WORKING;
     o->state = STATE_WORKING;
 }
 }
 
 
+static int func_getvar (void *vo, const char *name, NCDValue *out)
+{
+    struct instance *o = vo;
+    ASSERT(o->state == STATE_UP)
+    
+    return NCDModuleProcess_GetVar(&o->process, name, out);
+}
+
+static NCDModuleInst * func_getobj (void *vo, const char *name)
+{
+    struct instance *o = vo;
+    ASSERT(o->state == STATE_UP)
+    
+    return NCDModuleProcess_GetObj(&o->process, name);
+}
+
 static const struct NCDModule modules[] = {
 static const struct NCDModule modules[] = {
     {
     {
         .type = "call",
         .type = "call",
         .func_new = func_new,
         .func_new = func_new,
         .func_die = func_die,
         .func_die = func_die,
-        .func_clean = func_clean
+        .func_clean = func_clean,
+        .func_getvar = func_getvar,
+        .func_getobj = func_getobj
     }, {
     }, {
         .type = NULL
         .type = NULL
     }
     }