Просмотр исходного кода

ncd: NCDModuleInst: don't store "args" and "method_user" in the NCDModuleInst struct. Instead, pass them at instance
initialization, via a struct.

ambrop7 13 лет назад
Родитель
Сommit
ed95b609d4
71 измененных файлов с 491 добавлено и 464 удалено
  1. 5 3
      ncd/NCDModule.c
  2. 26 3
      ncd/NCDModule.h
  3. 2 2
      ncd/modules/alias.c
  4. 24 24
      ncd/modules/arithmetic.c
  5. 6 6
      ncd/modules/assert.c
  6. 17 17
      ncd/modules/blocker.c
  7. 4 4
      ncd/modules/call.c
  8. 16 16
      ncd/modules/call2.c
  9. 2 2
      ncd/modules/choose.c
  10. 3 3
      ncd/modules/command_template.c
  11. 2 2
      ncd/modules/command_template.h
  12. 4 4
      ncd/modules/concat.c
  13. 2 2
      ncd/modules/concatv.c
  14. 2 2
      ncd/modules/daemon.c
  15. 8 8
      ncd/modules/depend.c
  16. 4 4
      ncd/modules/dynamic_depend.c
  17. 2 2
      ncd/modules/exit.c
  18. 2 2
      ncd/modules/explode.c
  19. 10 10
      ncd/modules/file.c
  20. 4 4
      ncd/modules/foreach.c
  21. 2 2
      ncd/modules/from_string.c
  22. 2 2
      ncd/modules/getargs.c
  23. 6 6
      ncd/modules/if.c
  24. 2 2
      ncd/modules/imperative.c
  25. 2 2
      ncd/modules/implode.c
  26. 4 4
      ncd/modules/index.c
  27. 34 34
      ncd/modules/list.c
  28. 10 10
      ncd/modules/logical.c
  29. 4 4
      ncd/modules/multidepend.c
  30. 2 2
      ncd/modules/net_backend_badvpn.c
  31. 2 2
      ncd/modules/net_backend_rfkill.c
  32. 2 2
      ncd/modules/net_backend_waitdevice.c
  33. 2 2
      ncd/modules/net_backend_waitlink.c
  34. 2 2
      ncd/modules/net_backend_wpa_supplicant.c
  35. 2 2
      ncd/modules/net_dns.c
  36. 37 37
      ncd/modules/net_iptables.c
  37. 3 3
      ncd/modules/net_ipv4_addr.c
  38. 7 7
      ncd/modules/net_ipv4_addr_in_network.c
  39. 2 2
      ncd/modules/net_ipv4_arp_probe.c
  40. 2 2
      ncd/modules/net_ipv4_dhcp.c
  41. 3 3
      ncd/modules/net_ipv4_route.c
  42. 3 3
      ncd/modules/net_ipv6_addr.c
  43. 7 7
      ncd/modules/net_ipv6_addr_in_network.c
  44. 3 3
      ncd/modules/net_ipv6_route.c
  45. 2 2
      ncd/modules/net_ipv6_wait_dynamic_addr.c
  46. 2 2
      ncd/modules/net_up.c
  47. 5 5
      ncd/modules/net_watch_interfaces.c
  48. 6 6
      ncd/modules/netmask.c
  49. 5 5
      ncd/modules/ondemand.c
  50. 10 10
      ncd/modules/parse.c
  51. 21 19
      ncd/modules/print.c
  52. 8 8
      ncd/modules/process_manager.c
  53. 4 4
      ncd/modules/reboot.c
  54. 10 10
      ncd/modules/ref.c
  55. 4 4
      ncd/modules/regex_match.c
  56. 4 4
      ncd/modules/run.c
  57. 8 8
      ncd/modules/runonce.c
  58. 2 2
      ncd/modules/sleep.c
  59. 5 5
      ncd/modules/spawn.c
  60. 2 2
      ncd/modules/strcmp.c
  61. 5 5
      ncd/modules/sys_evdev.c
  62. 5 5
      ncd/modules/sys_request_client.c
  63. 8 8
      ncd/modules/sys_request_server.c
  64. 5 5
      ncd/modules/sys_watch_directory.c
  65. 5 5
      ncd/modules/sys_watch_input.c
  66. 5 5
      ncd/modules/sys_watch_usb.c
  67. 2 2
      ncd/modules/to_string.c
  68. 5 5
      ncd/modules/try.c
  69. 44 44
      ncd/modules/value.c
  70. 14 14
      ncd/modules/valuemetic.c
  71. 5 5
      ncd/modules/var.c

+ 5 - 3
ncd/NCDModule.c

@@ -87,8 +87,6 @@ void NCDModuleInst_Init (NCDModuleInst *n, const struct NCDModule *m, void *mem,
     
     // init arguments
     n->m = m;
-    n->method_user = (method_object ? method_object->user : NULL);
-    n->args = args;
     n->params = params;
     n->iparams = iparams;
     
@@ -103,7 +101,11 @@ void NCDModuleInst_Init (NCDModuleInst *n, const struct NCDModule *m, void *mem,
     
     DebugObject_Init(&n->d_obj);
     
-    n->m->func_new2(n->inst_user, n);
+    struct NCDModuleInst_new_params new_params;
+    new_params.method_user = (method_object ? method_object->user : NULL);
+    new_params.args = args;
+    
+    n->m->func_new2(n->inst_user, n, &new_params);
 }
 
 void NCDModuleInst_Free (NCDModuleInst *n)

+ 26 - 3
ncd/NCDModule.h

@@ -224,6 +224,31 @@ struct NCDModuleInitParams {
     BRandom2 *random2;
 };
 
+/**
+ * Contains parameters to the module initialization function
+ * ({@link NCDModule_func_new2}) that are passed indirectly.
+ */
+struct NCDModuleInst_new_params {
+    /**
+     * A reference to the argument list for the module instance.
+     * The reference remains valid as long as the backend instance
+     * exists.
+     */
+    NCDValRef args;
+    
+    /**
+     * If the module instance corresponds to a method-like statement,
+     * this pointer identifies the object it is being invoked with.
+     * If the object is a statement (i.e. a {@link NCDModuleInst}), then this
+     * will be the NCDModuleInst pointer, and {@link NCDModuleInst_Backend_GetUser}
+     * can be called on this to retrieve the user pointer of the object.
+     * On the other hand, if this is a method on an internal object built using
+     * only {@link NCDObject_Build} or {@link NCDObject_Build2}, this pointer will
+     * be whatever was passed as the "user" argument to those functions.
+     */
+    void *method_user;
+};
+
 /**
  * Contains parameters to {@link NCDModuleInst_Init} that are passed indirectly.
  * This only contains parameters related to communication between the backend
@@ -291,8 +316,6 @@ struct NCDModuleInst_iparams {
  */
 typedef struct NCDModuleInst_s {
     const struct NCDModule *m;
-    void *method_user;
-    NCDValRef args;
     const struct NCDModuleInst_params *params;
     const struct NCDModuleInst_iparams *iparams;
     void *inst_user;
@@ -657,7 +680,7 @@ typedef void (*NCDModule_func_globalfree) (void);
  * @param i module backend instance handler. The backend may only use this handle via
  *          the Backend functions of {@link NCDModuleInst}.
  */
-typedef void (*NCDModule_func_new2) (void *o, NCDModuleInst *i);
+typedef void (*NCDModule_func_new2) (void *o, NCDModuleInst *i, const struct NCDModuleInst_new_params *params);
 
 /**
  * Handler called to request termination of a backend instance.

+ 2 - 2
ncd/modules/alias.c

@@ -75,11 +75,11 @@ static int split_string_inplace (char *str, char del)
     return num_extra_parts;
 }
 
-static void func_new (void *unused, NCDModuleInst *i)
+static void func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef target_arg;
-    if (!NCDVal_ListRead(i->args, 1, &target_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &target_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 24 - 24
ncd/modules/arithmetic.c

@@ -174,14 +174,14 @@ static int compute_modulo (NCDModuleInst *i, uintmax_t n1, uintmax_t n2, char *o
     return 1;
 }
 
-static void new_templ (void *vo, NCDModuleInst *i, compute_func cfunc)
+static void new_templ (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, compute_func cfunc)
 {
     struct instance *o = vo;
     o->i = i;
     
     NCDValRef n1_arg;
     NCDValRef n2_arg;
-    if (!NCDVal_ListRead(i->args, 2, &n1_arg, &n2_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &n1_arg, &n2_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -224,59 +224,59 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return 0;
 }
 
-static void func_new_lesser (void *vo, NCDModuleInst *i)
+static void func_new_lesser (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_lesser);
+    new_templ(vo, i, params, compute_lesser);
 }
 
-static void func_new_greater (void *vo, NCDModuleInst *i)
+static void func_new_greater (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_greater);
+    new_templ(vo, i, params, compute_greater);
 }
 
-static void func_new_lesser_equal (void *vo, NCDModuleInst *i)
+static void func_new_lesser_equal (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_lesser_equal);
+    new_templ(vo, i, params, compute_lesser_equal);
 }
 
-static void func_new_greater_equal (void *vo, NCDModuleInst *i)
+static void func_new_greater_equal (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_greater_equal);
+    new_templ(vo, i, params, compute_greater_equal);
 }
 
-static void func_new_equal (void *vo, NCDModuleInst *i)
+static void func_new_equal (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_equal);
+    new_templ(vo, i, params, compute_equal);
 }
 
-static void func_new_different (void *vo, NCDModuleInst *i)
+static void func_new_different (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_different);
+    new_templ(vo, i, params, compute_different);
 }
 
-static void func_new_add (void *vo, NCDModuleInst *i)
+static void func_new_add (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_add);
+    new_templ(vo, i, params, compute_add);
 }
 
-static void func_new_subtract (void *vo, NCDModuleInst *i)
+static void func_new_subtract (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_subtract);
+    new_templ(vo, i, params, compute_subtract);
 }
 
-static void func_new_multiply (void *vo, NCDModuleInst *i)
+static void func_new_multiply (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_multiply);
+    new_templ(vo, i, params, compute_multiply);
 }
 
-static void func_new_divide (void *vo, NCDModuleInst *i)
+static void func_new_divide (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_divide);
+    new_templ(vo, i, params, compute_divide);
 }
 
-static void func_new_modulo (void *vo, NCDModuleInst *i)
+static void func_new_modulo (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_modulo);
+    new_templ(vo, i, params, compute_modulo);
 }
 
 static const struct NCDModule modules[] = {

+ 6 - 6
ncd/modules/assert.c

@@ -47,11 +47,11 @@
 
 #define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
 
-static void func_new_common (NCDModuleInst *i, int is_false)
+static void func_new_common (NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_false)
 {
     // check arguments
     NCDValRef cond_arg;
-    if (!NCDVal_ListRead(i->args, 1, &cond_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &cond_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -76,14 +76,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new (void *unused, NCDModuleInst *i)
+static void func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_common(i, 0);
+    func_new_common(i, params, 0);
 }
 
-static void func_new_false (void *unused, NCDModuleInst *i)
+static void func_new_false (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_common(i, 1);
+    func_new_common(i, params, 1);
 }
 
 static const struct NCDModule modules[] = {

+ 17 - 17
ncd/modules/blocker.c

@@ -102,13 +102,13 @@ struct use_instance {
     LinkedList1Node blocker_node;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
-    if (!NCDVal_ListRead(o->i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -165,12 +165,12 @@ static void func_die (void *vo)
     o->dying = 1;
 }
 
-static void updown_func_new_templ (NCDModuleInst *i, int up, int first_down)
+static void updown_func_new_templ (NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int up, int first_down)
 {
     ASSERT(!first_down || up)
     
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -179,7 +179,7 @@ static void updown_func_new_templ (NCDModuleInst *i, int up, int first_down)
     NCDModuleInst_Backend_Up(i);
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     if (first_down || mo->up != up) {
         // signal users
@@ -207,34 +207,34 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void up_func_new (void *unused, NCDModuleInst *i)
+static void up_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    updown_func_new_templ(i, 1, 0);
+    updown_func_new_templ(i, params, 1, 0);
 }
 
-static void down_func_new (void *unused, NCDModuleInst *i)
+static void down_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    updown_func_new_templ(i, 0, 0);
+    updown_func_new_templ(i, params, 0, 0);
 }
 
-static void downup_func_new (void *unused, NCDModuleInst *i)
+static void downup_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    updown_func_new_templ(i, 1, 1);
+    updown_func_new_templ(i, params, 1, 1);
 }
 
-static void rdownup_func_new (void *vo, NCDModuleInst *i)
+static void rdownup_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct rdownup_instance *o = vo;
     o->i = i;
     
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get blocker
-    struct instance *blk = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *blk = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // set blocker
     o->blocker = blk;
@@ -278,19 +278,19 @@ static void rdownup_func_die (void *vo)
     NCDModuleInst_Backend_Dead(o->i);
 }
 
-static void use_func_new (void *vo, NCDModuleInst *i)
+static void use_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct use_instance *o = vo;
     o->i = i;
     
     // check arguments
-    if (!NCDVal_ListRead(o->i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // set blocker
-    o->blocker = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    o->blocker = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // add to blocker's list
     LinkedList1_Append(&o->blocker->users, &o->blocker_node);

+ 4 - 4
ncd/modules/call.c

@@ -149,7 +149,7 @@ static int process_func_getspecialobj (struct instance *o, const char *name, NCD
     return 0;
 }
 
-static void callrefhere_func_new (void *vo, NCDModuleInst *i)
+static void callrefhere_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct callrefhere_instance *o = vo;
     o->i = i;
@@ -176,7 +176,7 @@ static void callrefhere_func_die (void *vo)
     NCDModuleInst_Backend_Dead(o->i);
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -184,7 +184,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // check arguments
     NCDValRef template_name_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(i->args, 2, &template_name_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &template_name_arg, &args_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -225,7 +225,7 @@ static void func_new (void *vo, NCDModuleInst *i)
                                         (NCDModuleProcess_func_getspecialobj)process_func_getspecialobj);
         
         // set callrefhere
-        o->crh = (o->i->method_user ? NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user) : NULL);
+        o->crh = (params->method_user ? NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user) : NULL);
         
         // add to callrefhere's calls list
         if (o->crh) {

+ 16 - 16
ncd/modules/call2.c

@@ -169,11 +169,11 @@ static void instance_free (struct instance *o)
     NCDModuleInst_Backend_Dead(o->i);
 }
 
-static void func_new_call (void *vo, NCDModuleInst *i)
+static void func_new_call (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef template_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(i->args, 2, &template_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &template_arg, &args_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -190,10 +190,10 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_embcall (void *vo, NCDModuleInst *i)
+static void func_new_embcall (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef template_arg;
-    if (!NCDVal_ListRead(i->args, 1, &template_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &template_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -210,12 +210,12 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_call_if (void *vo, NCDModuleInst *i)
+static void func_new_call_if (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef cond_arg;
     NCDValRef template_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(i->args, 3, &cond_arg, &template_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 3, &cond_arg, &template_arg, &args_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -238,11 +238,11 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_embcall_if (void *vo, NCDModuleInst *i)
+static void func_new_embcall_if (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef cond_arg;
     NCDValRef template_arg;
-    if (!NCDVal_ListRead(i->args, 2, &cond_arg, &template_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &cond_arg, &template_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -265,13 +265,13 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_call_ifelse (void *vo, NCDModuleInst *i)
+static void func_new_call_ifelse (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef cond_arg;
     NCDValRef template_arg;
     NCDValRef else_template_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(i->args, 4, &cond_arg, &template_arg, &else_template_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 4, &cond_arg, &template_arg, &else_template_arg, &args_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -296,12 +296,12 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_embcall_ifelse (void *vo, NCDModuleInst *i)
+static void func_new_embcall_ifelse (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef cond_arg;
     NCDValRef template_arg;
     NCDValRef else_template_arg;
-    if (!NCDVal_ListRead(i->args, 3, &cond_arg, &template_arg, &else_template_arg)) {
+    if (!NCDVal_ListRead(params->args, 3, &cond_arg, &template_arg, &else_template_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -326,15 +326,15 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_embcall_multif (void *vo, NCDModuleInst *i)
+static void func_new_embcall_multif (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     const char *template_name = NULL;
     
-    size_t count = NCDVal_ListCount(i->args);
+    size_t count = NCDVal_ListCount(params->args);
     size_t j = 0;
     
     while (j < count) {
-        NCDValRef arg = NCDVal_ListGet(i->args, j);
+        NCDValRef arg = NCDVal_ListGet(params->args, j);
         
         if (j == count - 1) {
             if (!NCDVal_IsStringNoNulls(arg)) {
@@ -346,7 +346,7 @@ static void func_new_embcall_multif (void *vo, NCDModuleInst *i)
             break;
         }
         
-        NCDValRef arg2 = NCDVal_ListGet(i->args, j + 1);
+        NCDValRef arg2 = NCDVal_ListGet(params->args, j + 1);
         
         if (!NCDVal_IsString(arg) || !NCDVal_IsStringNoNulls(arg2)) {
             ModuleLog(i, BLOG_ERROR, "bad arguments");

+ 2 - 2
ncd/modules/choose.c

@@ -54,7 +54,7 @@ struct instance {
     NCDValRef result;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -62,7 +62,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // read arguments
     NCDValRef arg_choices;
     NCDValRef arg_default_result;
-    if (!NCDVal_ListRead(i->args, 2, &arg_choices, &arg_default_result)) {
+    if (!NCDVal_ListRead(params->args, 2, &arg_choices, &arg_default_result)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 3 - 3
ncd/modules/command_template.c

@@ -118,7 +118,7 @@ static void process_handler (command_template_instance *o, int normally, uint8_t
     }
 }
 
-void command_template_new (command_template_instance *o, NCDModuleInst *i, command_template_build_cmdline build_cmdline, command_template_free_func free_func, void *user, int blog_channel, BEventLock *elock)
+void command_template_new (command_template_instance *o, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, command_template_build_cmdline build_cmdline, command_template_free_func free_func, void *user, int blog_channel, BEventLock *elock)
 {
     // init arguments
     o->i = i;
@@ -127,13 +127,13 @@ void command_template_new (command_template_instance *o, NCDModuleInst *i, comma
     o->blog_channel = blog_channel;
     
     // build do command
-    if (!build_cmdline(o->i, 0, &o->do_exec, &o->do_cmdline)) {
+    if (!build_cmdline(o->i, params->args, 0, &o->do_exec, &o->do_cmdline)) {
         NCDModuleInst_Backend_Log(o->i, o->blog_channel, BLOG_ERROR, "build_cmdline do callback failed");
         goto fail0;
     }
     
     // build undo command
-    if (!build_cmdline(o->i, 1, &o->undo_exec, &o->undo_cmdline)) {
+    if (!build_cmdline(o->i, params->args, 1, &o->undo_exec, &o->undo_cmdline)) {
         NCDModuleInst_Backend_Log(o->i, o->blog_channel, BLOG_ERROR, "build_cmdline undo callback failed");
         goto fail1;
     }

+ 2 - 2
ncd/modules/command_template.h

@@ -39,7 +39,7 @@
 #include <ncd/BEventLock.h>
 #include <ncd/NCDModule.h>
 
-typedef int (*command_template_build_cmdline) (NCDModuleInst *i, int remove, char **exec, CmdLine *cl);
+typedef int (*command_template_build_cmdline) (NCDModuleInst *i, NCDValRef args, int remove, char **exec, CmdLine *cl);
 typedef void (*command_template_free_func) (void *user, int is_error);
 
 typedef struct {
@@ -56,7 +56,7 @@ typedef struct {
     BProcess process;
 } command_template_instance;
 
-void command_template_new (command_template_instance *o, NCDModuleInst *i, command_template_build_cmdline build_cmdline, command_template_free_func free_func, void *user, int blog_channel, BEventLock *elock);
+void command_template_new (command_template_instance *o, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, command_template_build_cmdline build_cmdline, command_template_free_func free_func, void *user, int blog_channel, BEventLock *elock);
 void command_template_die (command_template_instance *o);
 
 #endif

+ 4 - 4
ncd/modules/concat.c

@@ -50,7 +50,7 @@ struct instance {
     size_t len;
 };
 
-static void func_new2 (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -63,9 +63,9 @@ static void func_new2 (void *vo, NCDModuleInst *i)
     }
     
     // append arguments
-    size_t count = NCDVal_ListCount(i->args);
+    size_t count = NCDVal_ListCount(params->args);
     for (size_t j = 0; j < count; j++) {
-        NCDValRef arg = NCDVal_ListGet(i->args, j);
+        NCDValRef arg = NCDVal_ListGet(params->args, j);
         
         if (!NCDVal_IsString(arg)) {
             ModuleLog(i, BLOG_ERROR, "wrong type");
@@ -121,7 +121,7 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
 static const struct NCDModule modules[] = {
     {
         .type = "concat",
-        .func_new2 = func_new2,
+        .func_new2 = func_new,
         .func_die = func_die,
         .func_getvar = func_getvar,
         .alloc_size = sizeof(struct instance)

+ 2 - 2
ncd/modules/concatv.c

@@ -50,14 +50,14 @@ struct instance {
     size_t len;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef strings_arg;
-    if (!NCDVal_ListRead(o->i->args, 1, &strings_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &strings_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/daemon.c

@@ -204,13 +204,13 @@ static void process_handler (struct instance *o, int normally, uint8_t normally_
     o->state = STATE_RETRYING;
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // read arguments
-    if (!NCDVal_ListRead(i->args, 1, &o->cmd_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &o->cmd_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 8 - 8
ncd/modules/depend.c

@@ -163,14 +163,14 @@ static int func_globalinit (struct NCDModuleInitParams params)
     return 1;
 }
 
-static void provide_func_new_templ (void *vo, NCDModuleInst *i, int event)
+static void provide_func_new_templ (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int event)
 {
     struct provide *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef name_arg;
-    if (!NCDVal_ListRead(i->args, 1, &name_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &name_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -215,14 +215,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void provide_func_new (void *vo, NCDModuleInst *i)
+static void provide_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    provide_func_new_templ(vo, i, 0);
+    provide_func_new_templ(vo, i, params, 0);
 }
 
-static void provide_event_func_new (void *vo, NCDModuleInst *i)
+static void provide_event_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    provide_func_new_templ(vo, i, 1);
+    provide_func_new_templ(vo, i, params, 1);
 }
 
 static void provide_free (struct provide *o)
@@ -279,14 +279,14 @@ static void provide_func_die (void *vo)
     }
 }
 
-static void depend_func_new (void *vo, NCDModuleInst *i)
+static void depend_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct depend *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef name_arg;
-    if (!NCDVal_ListRead(i->args, 1, &name_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &name_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 4 - 4
ncd/modules/dynamic_depend.c

@@ -268,14 +268,14 @@ static int func_globalinit (struct NCDModuleInitParams params)
     return 1;
 }
 
-static void provide_func_new (void *vo, NCDModuleInst *i)
+static void provide_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct provide *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef name_arg;
-    if (!NCDVal_ListRead(i->args, 2, &name_arg, &o->order_value)) {
+    if (!NCDVal_ListRead(params->args, 2, &name_arg, &o->order_value)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -363,14 +363,14 @@ static void provide_func_die (void *vo)
     name_start_resetting(n);
 }
 
-static void depend_func_new (void *vo, NCDModuleInst *i)
+static void depend_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct depend *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef name_arg;
-    if (!NCDVal_ListRead(i->args, 1, &name_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &name_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/exit.c

@@ -46,11 +46,11 @@
 
 #define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
 
-static void func_new (void *unused, NCDModuleInst *i)
+static void func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
     NCDValRef exit_code_arg;
-    if (!NCDVal_ListRead(i->args, 1, &exit_code_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &exit_code_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/explode.c

@@ -69,7 +69,7 @@ struct substring {
     size_t len;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -78,7 +78,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     NCDValRef delimiter_arg;
     NCDValRef input_arg;
     NCDValRef limit_arg = NCDVal_NewInvalid();
-    if (!NCDVal_ListRead(i->args, 2, &delimiter_arg, &input_arg) && !NCDVal_ListRead(i->args, 3, &delimiter_arg, &input_arg, &limit_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &delimiter_arg, &input_arg) && !NCDVal_ListRead(params->args, 3, &delimiter_arg, &input_arg, &limit_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 10 - 10
ncd/modules/file.c

@@ -105,14 +105,14 @@ struct stat_instance {
     struct stat result;
 };
 
-static void read_func_new (void *vo, NCDModuleInst *i)
+static void read_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct read_instance *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef filename_arg;
-    if (!NCDVal_ListRead(i->args, 1, &filename_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &filename_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -161,12 +161,12 @@ static int read_func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValR
     return 0;
 }
 
-static void write_func_new (void *unused, NCDModuleInst *i)
+static void write_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef filename_arg;
     NCDValRef contents_arg;
-    if (!NCDVal_ListRead(i->args, 2, &filename_arg, &contents_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &filename_arg, &contents_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -190,13 +190,13 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void stat_func_new_common (void *vo, NCDModuleInst *i, int is_lstat)
+static void stat_func_new_common (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_lstat)
 {
     struct stat_instance *o = vo;
     o->i = i;
     
     NCDValRef filename_arg;
-    if (!NCDVal_ListRead(i->args, 1, &filename_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &filename_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -234,14 +234,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void stat_func_new (void *vo, NCDModuleInst *i)
+static void stat_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    stat_func_new_common(vo, i, 0);
+    stat_func_new_common(vo, i, params, 0);
 }
 
-static void lstat_func_new (void *vo, NCDModuleInst *i)
+static void lstat_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    stat_func_new_common(vo, i, 1);
+    stat_func_new_common(vo, i, params, 1);
 }
 
 static int stat_func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *out)

+ 4 - 4
ncd/modules/foreach.c

@@ -564,13 +564,13 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_foreach (void *vo, NCDModuleInst *i)
+static void func_new_foreach (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef arg_collection;
     NCDValRef arg_template;
     NCDValRef arg_args;
-    if (!NCDVal_ListRead(i->args, 3, &arg_collection, &arg_template, &arg_args)) {
+    if (!NCDVal_ListRead(params->args, 3, &arg_collection, &arg_template, &arg_args)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -605,14 +605,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_foreach_emb (void *vo, NCDModuleInst *i)
+static void func_new_foreach_emb (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef arg_collection;
     NCDValRef arg_template;
     NCDValRef arg_name1;
     NCDValRef arg_name2 = NCDVal_NewInvalid();
-    if (!NCDVal_ListRead(i->args, 3, &arg_collection, &arg_template, &arg_name1) && !NCDVal_ListRead(i->args, 4, &arg_collection, &arg_template, &arg_name1, &arg_name2)) {
+    if (!NCDVal_ListRead(params->args, 3, &arg_collection, &arg_template, &arg_name1) && !NCDVal_ListRead(params->args, 4, &arg_collection, &arg_template, &arg_name1, &arg_name2)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/from_string.c

@@ -50,14 +50,14 @@ struct instance {
     NCDValRef val;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef str_arg;
-    if (!NCDVal_ListRead(i->args, 1, &str_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &str_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/getargs.c

@@ -43,12 +43,12 @@
 
 #define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
 
-static void func_new (void *unused, NCDModuleInst *i)
+static void func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDModuleInst_Backend_SetUser(i, i);
     
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 6 - 6
ncd/modules/if.c

@@ -48,11 +48,11 @@
 
 #define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
 
-static void new_templ (NCDModuleInst *i, int is_not)
+static void new_templ (NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_not)
 {
     // check arguments
     NCDValRef arg;
-    if (!NCDVal_ListRead(i->args, 1, &arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -76,14 +76,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new (void *unused, NCDModuleInst *i)
+static void func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(i, 0);
+    new_templ(i, params, 0);
 }
 
-static void func_new_not (void *unused, NCDModuleInst *i)
+static void func_new_not (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(i, 1);
+    new_templ(i, params, 1);
 }
 
 static const struct NCDModule modules[] = {

+ 2 - 2
ncd/modules/imperative.c

@@ -224,7 +224,7 @@ static void deinit_timer_handler (struct instance *o)
     o->state = STATE_DEINIT_CLEANING;
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -234,7 +234,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     NCDValRef init_args;
     NCDValRef deinit_template_arg;
     NCDValRef deinit_timeout_arg;
-    if (!NCDVal_ListRead(i->args, 5, &init_template_arg, &init_args, &deinit_template_arg, &o->deinit_args, &deinit_timeout_arg)) {
+    if (!NCDVal_ListRead(params->args, 5, &init_template_arg, &init_args, &deinit_template_arg, &o->deinit_args, &deinit_timeout_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/implode.c

@@ -52,7 +52,7 @@ struct instance {
     size_t result_len;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -60,7 +60,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // read arguments
     NCDValRef glue_arg;
     NCDValRef pieces_arg;
-    if (!NCDVal_ListRead(i->args, 2, &glue_arg, &pieces_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &glue_arg, &pieces_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 4 - 4
ncd/modules/index.c

@@ -72,11 +72,11 @@ static void func_new_templ (void *vo, NCDModuleInst *i, size_t value)
     NCDModuleInst_Backend_Up(o->i);
 }
 
-static void func_new_from_value (void *vo, NCDModuleInst *i)
+static void func_new_from_value (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef arg_value;
-    if (!NCDVal_ListRead(i->args, 1, &arg_value)) {
+    if (!NCDVal_ListRead(params->args, 1, &arg_value)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -106,9 +106,9 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_from_index (void *vo, NCDModuleInst *i)
+static void func_new_from_index (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    struct instance *index = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *index = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // check overflow
     if (index->value == SIZE_MAX) {

+ 34 - 34
ncd/modules/list.c

@@ -316,7 +316,7 @@ fail:
     return 0;
 }
 
-static void func_new_list (void *vo, NCDModuleInst *i)
+static void func_new_list (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -325,7 +325,7 @@ static void func_new_list (void *vo, NCDModuleInst *i)
     IndexedList_Init(&o->il);
     
     // append contents
-    if (!append_list_contents(i, o, i->args)) {
+    if (!append_list_contents(i, o, params->args)) {
         goto fail1;
     }
     
@@ -339,7 +339,7 @@ fail1:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_listfrom (void *vo, NCDModuleInst *i)
+static void func_new_listfrom (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -348,7 +348,7 @@ static void func_new_listfrom (void *vo, NCDModuleInst *i)
     IndexedList_Init(&o->il);
     
     // append contents contents
-    if (!append_list_contents_contents(i, o, i->args)) {
+    if (!append_list_contents_contents(i, o, params->args)) {
         goto fail1;
     }
     
@@ -398,17 +398,17 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return 0;
 }
 
-static void append_func_new (void *unused, NCDModuleInst *i)
+static void append_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
     NCDValRef arg;
-    if (!NCDVal_ListRead(i->args, 1, &arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // append
     if (!insert_value(i, mo, arg, list_count(mo))) {
@@ -424,11 +424,11 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void appendv_func_new (void *unused, NCDModuleInst *i)
+static void appendv_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
     NCDValRef arg;
-    if (!NCDVal_ListRead(i->args, 1, &arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -438,7 +438,7 @@ static void appendv_func_new (void *unused, NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // append
     if (!append_list_contents(i, mo, arg)) {
@@ -454,19 +454,19 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void length_func_new (void *vo, NCDModuleInst *i)
+static void length_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct length_instance *o = vo;
     o->i = i;
     
     // check arguments
-    if (!NCDVal_ListRead(o->i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // remember length
     o->length = list_count(mo);
@@ -506,14 +506,14 @@ static int length_func_getvar (void *vo, const char *name, NCDValMem *mem, NCDVa
     return 0;
 }
     
-static void get_func_new (void *vo, NCDModuleInst *i)
+static void get_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct get_instance *o = vo;
     o->i = i;
     
     // check arguments
     NCDValRef index_arg;
-    if (!NCDVal_ListRead(o->i->args, 1, &index_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &index_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -528,7 +528,7 @@ static void get_func_new (void *vo, NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // check index
     if (index >= list_count(mo)) {
@@ -585,16 +585,16 @@ static int get_func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRe
     return 0;
 }
 
-static void shift_func_new (void *unused, NCDModuleInst *i)
+static void shift_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // check first
     if (list_count(mo) == 0) {
@@ -614,20 +614,20 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void contains_func_new (void *vo, NCDModuleInst *i)
+static void contains_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct contains_instance *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef value_arg;
-    if (!NCDVal_ListRead(i->args, 1, &value_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &value_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // search
     o->contains = !!find_elem(mo, value_arg, 0, NULL);
@@ -665,7 +665,7 @@ static int contains_func_getvar (void *vo, const char *name, NCDValMem *mem, NCD
     return 0;
 }
 
-static void find_func_new (void *vo, NCDModuleInst *i)
+static void find_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct find_instance *o = vo;
     o->i = i;
@@ -673,7 +673,7 @@ static void find_func_new (void *vo, NCDModuleInst *i)
     // read arguments
     NCDValRef start_pos_arg;
     NCDValRef value_arg;
-    if (!NCDVal_ListRead(i->args, 2, &start_pos_arg, &value_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &start_pos_arg, &value_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -690,7 +690,7 @@ static void find_func_new (void *vo, NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // find
     o->is_found = !!find_elem(mo, value_arg, start_pos, &o->found_pos);
@@ -744,11 +744,11 @@ static int find_func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValR
     return 0;
 }
 
-static void removeat_func_new (void *unused, NCDModuleInst *i)
+static void removeat_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef remove_pos_arg;
-    if (!NCDVal_ListRead(i->args, 1, &remove_pos_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &remove_pos_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -765,7 +765,7 @@ static void removeat_func_new (void *unused, NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // check position
     if (remove_pos >= list_count(mo)) {
@@ -785,17 +785,17 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void remove_func_new (void *unused, NCDModuleInst *i)
+static void remove_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef value_arg;
-    if (!NCDVal_ListRead(i->args, 1, &value_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &value_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // find element
     struct elem *e = find_elem(mo, value_arg, 0, NULL);
@@ -816,16 +816,16 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void set_func_new (void *unused, NCDModuleInst *i)
+static void set_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // remember old count
     uint64_t old_count = list_count(mo);
     
     // append contents of our lists
-    if (!append_list_contents_contents(i, mo, i->args)) {
+    if (!append_list_contents_contents(i, mo, params->args)) {
         goto fail0;
     }
     

+ 10 - 10
ncd/modules/logical.c

@@ -57,7 +57,7 @@ struct instance {
     int value;
 };
 
-static void func_new (void *vo, NCDModuleInst *i, int is_not, int is_or)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_not, int is_or)
 {
     struct instance *o = vo;
     o->i = i;
@@ -65,7 +65,7 @@ static void func_new (void *vo, NCDModuleInst *i, int is_not, int is_or)
     // compute value from arguments
     if (is_not) {
         NCDValRef arg;
-        if (!NCDVal_ListRead(i->args, 1, &arg)) {
+        if (!NCDVal_ListRead(params->args, 1, &arg)) {
             ModuleLog(o->i, BLOG_ERROR, "wrong arity");
             goto fail0;
         }
@@ -78,10 +78,10 @@ static void func_new (void *vo, NCDModuleInst *i, int is_not, int is_or)
     } else {
         o->value = (is_or ? 0 : 1);
         
-        size_t count = NCDVal_ListCount(i->args);
+        size_t count = NCDVal_ListCount(params->args);
         
         for (size_t j = 0; j < count; j++) {
-            NCDValRef arg = NCDVal_ListGet(i->args, j);
+            NCDValRef arg = NCDVal_ListGet(params->args, j);
             
             if (!NCDVal_IsString(arg)) {
                 ModuleLog(o->i, BLOG_ERROR, "wrong type");
@@ -106,19 +106,19 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_not (void *vo, NCDModuleInst *i)
+static void func_new_not (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new(vo, i, 1, 0);
+    func_new(vo, i, params, 1, 0);
 }
 
-static void func_new_or (void *vo, NCDModuleInst *i)
+static void func_new_or (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new(vo, i, 0, 1);
+    func_new(vo, i, params, 0, 1);
 }
 
-static void func_new_and (void *vo, NCDModuleInst *i)
+static void func_new_and (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new(vo, i, 0, 0);
+    func_new(vo, i, params, 0, 0);
 }
 
 static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *out)

+ 4 - 4
ncd/modules/multidepend.c

@@ -151,14 +151,14 @@ static int func_globalinit (struct NCDModuleInitParams params)
     return 1;
 }
 
-static void provide_func_new (void *vo, NCDModuleInst *i)
+static void provide_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct provide *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef name_arg;
-    if (!NCDVal_ListRead(o->i->args, 1, &name_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &name_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -235,14 +235,14 @@ static void provide_func_die (void *vo)
     }
 }
 
-static void depend_func_new (void *vo, NCDModuleInst *i)
+static void depend_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct depend *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef names_arg;
-    if (!NCDVal_ListRead(o->i->args, 1, &names_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &names_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_backend_badvpn.c

@@ -146,7 +146,7 @@ void timer_handler (struct instance *o)
     try_process(o);
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -156,7 +156,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     NCDValRef user_arg;
     NCDValRef exec_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(o->i->args, 4, &ifname_arg, &user_arg, &exec_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 4, &ifname_arg, &user_arg, &exec_arg, &args_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_backend_rfkill.c

@@ -130,7 +130,7 @@ static void monitor_handler (struct instance *o, struct rfkill_event event)
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -138,7 +138,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // check arguments
     NCDValRef type_arg;
     NCDValRef name_arg;
-    if (!NCDVal_ListRead(i->args, 2, &type_arg, &name_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &type_arg, &name_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_backend_waitdevice.c

@@ -115,14 +115,14 @@ out:
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
     NCDValRef arg;
-    if (!NCDVal_ListRead(i->args, 1, &arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_backend_waitlink.c

@@ -76,14 +76,14 @@ static void monitor_handler_error (struct instance *o)
     instance_free(o);
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
     NCDValRef arg;
-    if (!NCDVal_ListRead(i->args, 1, &arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_backend_wpa_supplicant.c

@@ -397,7 +397,7 @@ void process_pipe_handler_send (struct instance *o, uint8_t *data, int data_len)
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -407,7 +407,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     NCDValRef conf_arg;
     NCDValRef exec_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(o->i->args, 4, &ifname_arg, &conf_arg, &exec_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 4, &ifname_arg, &conf_arg, &exec_arg, &args_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_dns.c

@@ -186,7 +186,7 @@ static int func_globalinit (struct NCDModuleInitParams params)
     return 1;
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -197,7 +197,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // get arguments
     NCDValRef servers_arg;
     NCDValRef priority_arg;
-    if (!NCDVal_ListRead(o->i->args, 2, &servers_arg, &priority_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &servers_arg, &priority_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }

+ 37 - 37
ncd/modules/net_iptables.c

@@ -136,12 +136,12 @@ struct unlock_instance {
 
 static void unlock_free (struct unlock_instance *o);
 
-static int build_append_cmdline (NCDModuleInst *i, const char *prog, int remove, char **exec, CmdLine *cl)
+static int build_append_cmdline (NCDModuleInst *i, NCDValRef args, const char *prog, int remove, char **exec, CmdLine *cl)
 {
     // read arguments
     NCDValRef table_arg;
     NCDValRef chain_arg;
-    if (!NCDVal_ListReadHead(i->args, 2, &table_arg, &chain_arg)) {
+    if (!NCDVal_ListReadHead(args, 2, &table_arg, &chain_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -171,9 +171,9 @@ static int build_append_cmdline (NCDModuleInst *i, const char *prog, int remove,
     }
     
     // add additional arguments
-    size_t count = NCDVal_ListCount(i->args);
+    size_t count = NCDVal_ListCount(args);
     for (size_t j = 2; j < count; j++) {
-        NCDValRef arg = NCDVal_ListGet(i->args, j);
+        NCDValRef arg = NCDVal_ListGet(args, j);
         
         if (!NCDVal_IsStringNoNulls(arg)) {
             ModuleLog(i, BLOG_ERROR, "wrong type");
@@ -202,14 +202,14 @@ fail0:
     return 0;
 }
 
-static int build_policy_cmdline (NCDModuleInst *i, const char *prog, int remove, char **exec, CmdLine *cl)
+static int build_policy_cmdline (NCDModuleInst *i, NCDValRef args, const char *prog, int remove, char **exec, CmdLine *cl)
 {
     // read arguments
     NCDValRef table_arg;
     NCDValRef chain_arg;
     NCDValRef target_arg;
     NCDValRef revert_target_arg;
-    if (!NCDVal_ListRead(i->args, 4, &table_arg, &chain_arg, &target_arg, &revert_target_arg)) {
+    if (!NCDVal_ListRead(args, 4, &table_arg, &chain_arg, &target_arg, &revert_target_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -259,12 +259,12 @@ fail0:
     return 0;
 }
 
-static int build_newchain_cmdline (NCDModuleInst *i, const char *prog, int remove, char **exec, CmdLine *cl)
+static int build_newchain_cmdline (NCDModuleInst *i, NCDValRef args, const char *prog, int remove, char **exec, CmdLine *cl)
 {
     // read arguments
     NCDValRef table_arg = NCDVal_NewInvalid();
     NCDValRef chain_arg;
-    if (!NCDVal_ListRead(i->args, 1, &chain_arg) && !NCDVal_ListRead(i->args, 2, &table_arg, &chain_arg)) {
+    if (!NCDVal_ListRead(args, 1, &chain_arg) && !NCDVal_ListRead(args, 2, &table_arg, &chain_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -309,34 +309,34 @@ fail0:
     return 0;
 }
 
-static int build_iptables_append_cmdline (NCDModuleInst *i, int remove, char **exec, CmdLine *cl)
+static int build_iptables_append_cmdline (NCDModuleInst *i, NCDValRef args, int remove, char **exec, CmdLine *cl)
 {
-    return build_append_cmdline(i, "iptables", remove, exec, cl);
+    return build_append_cmdline(i, args, "iptables", remove, exec, cl);
 }
 
-static int build_iptables_policy_cmdline (NCDModuleInst *i, int remove, char **exec, CmdLine *cl)
+static int build_iptables_policy_cmdline (NCDModuleInst *i, NCDValRef args, int remove, char **exec, CmdLine *cl)
 {
-    return build_policy_cmdline(i, "iptables", remove, exec, cl);
+    return build_policy_cmdline(i, args, "iptables", remove, exec, cl);
 }
 
-static int build_iptables_newchain_cmdline (NCDModuleInst *i, int remove, char **exec, CmdLine *cl)
+static int build_iptables_newchain_cmdline (NCDModuleInst *i, NCDValRef args, int remove, char **exec, CmdLine *cl)
 {
-    return build_newchain_cmdline(i, "iptables", remove, exec, cl);
+    return build_newchain_cmdline(i, args, "iptables", remove, exec, cl);
 }
 
-static int build_ebtables_append_cmdline (NCDModuleInst *i, int remove, char **exec, CmdLine *cl)
+static int build_ebtables_append_cmdline (NCDModuleInst *i, NCDValRef args, int remove, char **exec, CmdLine *cl)
 {
-    return build_append_cmdline(i, "ebtables", remove, exec, cl);
+    return build_append_cmdline(i, args, "ebtables", remove, exec, cl);
 }
 
-static int build_ebtables_policy_cmdline (NCDModuleInst *i, int remove, char **exec, CmdLine *cl)
+static int build_ebtables_policy_cmdline (NCDModuleInst *i, NCDValRef args, int remove, char **exec, CmdLine *cl)
 {
-    return build_policy_cmdline(i, "ebtables", remove, exec, cl);
+    return build_policy_cmdline(i, args, "ebtables", remove, exec, cl);
 }
 
-static int build_ebtables_newchain_cmdline (NCDModuleInst *i, int remove, char **exec, CmdLine *cl)
+static int build_ebtables_newchain_cmdline (NCDModuleInst *i, NCDValRef args, int remove, char **exec, CmdLine *cl)
 {
-    return build_newchain_cmdline(i, "ebtables", remove, exec, cl);
+    return build_newchain_cmdline(i, args, "ebtables", remove, exec, cl);
 }
 
 static void lock_job_handler (struct lock_instance *o)
@@ -379,12 +379,12 @@ static void func_globalfree (void)
     BEventLock_Free(&iptables_lock);
 }
 
-static void func_new (void *vo, NCDModuleInst *i, command_template_build_cmdline build_cmdline)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, command_template_build_cmdline build_cmdline)
 {
     struct instance *o = vo;
     o->i = i;
     
-    command_template_new(&o->cti, i, build_cmdline, template_free_func, o, BLOG_CURRENT_CHANNEL, &iptables_lock);
+    command_template_new(&o->cti, i, params, build_cmdline, template_free_func, o, BLOG_CURRENT_CHANNEL, &iptables_lock);
 }
 
 void template_free_func (void *vo, int is_error)
@@ -397,34 +397,34 @@ void template_free_func (void *vo, int is_error)
     NCDModuleInst_Backend_Dead(o->i);
 }
 
-static void append_iptables_func_new (void *vo, NCDModuleInst *i)
+static void append_iptables_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new(vo, i, build_iptables_append_cmdline);
+    func_new(vo, i, params, build_iptables_append_cmdline);
 }
 
-static void policy_iptables_func_new (void *vo, NCDModuleInst *i)
+static void policy_iptables_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new(vo, i, build_iptables_policy_cmdline);
+    func_new(vo, i, params, build_iptables_policy_cmdline);
 }
 
-static void newchain_iptables_func_new (void *vo, NCDModuleInst *i)
+static void newchain_iptables_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new(vo, i, build_iptables_newchain_cmdline);
+    func_new(vo, i, params, build_iptables_newchain_cmdline);
 }
 
-static void append_ebtables_func_new (void *vo, NCDModuleInst *i)
+static void append_ebtables_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new(vo, i, build_ebtables_append_cmdline);
+    func_new(vo, i, params, build_ebtables_append_cmdline);
 }
 
-static void policy_ebtables_func_new (void *vo, NCDModuleInst *i)
+static void policy_ebtables_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new(vo, i, build_ebtables_policy_cmdline);
+    func_new(vo, i, params, build_ebtables_policy_cmdline);
 }
 
-static void newchain_ebtables_func_new (void *vo, NCDModuleInst *i)
+static void newchain_ebtables_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new(vo, i, build_ebtables_newchain_cmdline);
+    func_new(vo, i, params, build_ebtables_newchain_cmdline);
 }
 
 static void func_die (void *vo)
@@ -434,7 +434,7 @@ static void func_die (void *vo)
     command_template_die(&o->cti);
 }
 
-static void lock_func_new (void *vo, NCDModuleInst *i)
+static void lock_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct lock_instance *o = vo;
     o->i = i;
@@ -475,13 +475,13 @@ static void lock_func_die (void *vo)
     NCDModuleInst_Backend_Dead(o->i);
 }
 
-static void unlock_func_new (void *vo, NCDModuleInst *i)
+static void unlock_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct unlock_instance *o = vo;
     o->i = i;
     
     // get lock lock
-    struct lock_instance *lock = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct lock_instance *lock = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // make sure lock doesn't already have an unlock
     if (lock->unlock) {

+ 3 - 3
ncd/modules/net_ipv4_addr.c

@@ -56,7 +56,7 @@ struct instance {
     struct ipv4_ifaddr ifaddr;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -65,8 +65,8 @@ static void func_new (void *vo, NCDModuleInst *i)
     NCDValRef ifname_arg;
     NCDValRef addr_arg;
     NCDValRef prefix_arg = NCDVal_NewInvalid();
-    if (!NCDVal_ListRead(i->args, 2, &ifname_arg, &addr_arg) &&
-        !NCDVal_ListRead(i->args, 3, &ifname_arg, &addr_arg, &prefix_arg)
+    if (!NCDVal_ListRead(params->args, 2, &ifname_arg, &addr_arg) &&
+        !NCDVal_ListRead(params->args, 3, &ifname_arg, &addr_arg, &prefix_arg)
     ) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;

+ 7 - 7
ncd/modules/net_ipv4_addr_in_network.c

@@ -59,7 +59,7 @@ struct instance {
     int value;
 };
 
-static void func_new_common (void *vo, NCDModuleInst *i, int is_ifnot)
+static void func_new_common (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_ifnot)
 {
     struct instance *o = vo;
     o->i = i;
@@ -68,8 +68,8 @@ static void func_new_common (void *vo, NCDModuleInst *i, int is_ifnot)
     NCDValRef arg_addr;
     NCDValRef arg_net_addr;
     NCDValRef arg_net_prefix = NCDVal_NewInvalid();
-    if (!NCDVal_ListRead(i->args, 2, &arg_addr, &arg_net_addr) &&
-        !NCDVal_ListRead(i->args, 3, &arg_addr, &arg_net_addr, &arg_net_prefix) 
+    if (!NCDVal_ListRead(params->args, 2, &arg_addr, &arg_net_addr) &&
+        !NCDVal_ListRead(params->args, 3, &arg_addr, &arg_net_addr, &arg_net_prefix) 
     ) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
@@ -125,14 +125,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_normal (void *vo, NCDModuleInst *i)
+static void func_new_normal (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_common(vo, i, 0);
+    func_new_common(vo, i, params, 0);
 }
 
-static void func_new_ifnot (void *vo, NCDModuleInst *i)
+static void func_new_ifnot (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_common(vo, i, 1);
+    func_new_common(vo, i, params, 1);
 }
 
 static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *out)

+ 2 - 2
ncd/modules/net_ipv4_arp_probe.c

@@ -118,7 +118,7 @@ static void arpprobe_handler (struct instance *o, int event)
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -126,7 +126,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // read arguments
     NCDValRef arg_ifname;
     NCDValRef arg_addr;
-    if (!NCDVal_ListRead(i->args, 2, &arg_ifname, &arg_addr)) {
+    if (!NCDVal_ListRead(params->args, 2, &arg_ifname, &arg_addr)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_ipv4_dhcp.c

@@ -99,7 +99,7 @@ static void dhcp_handler (struct instance *o, int event)
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -107,7 +107,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // check arguments
     NCDValRef ifname_arg;
     NCDValRef opts_arg = NCDVal_NewInvalid();
-    if (!NCDVal_ListRead(i->args, 1, &ifname_arg) && !NCDVal_ListRead(i->args, 2, &ifname_arg, &opts_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &ifname_arg) && !NCDVal_ListRead(params->args, 2, &ifname_arg, &opts_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 3 - 3
ncd/modules/net_ipv4_route.c

@@ -66,7 +66,7 @@ struct instance {
     const char *ifname;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -77,8 +77,8 @@ static void func_new (void *vo, NCDModuleInst *i)
     NCDValRef gateway_arg;
     NCDValRef metric_arg;
     NCDValRef ifname_arg;
-    if (!NCDVal_ListRead(i->args, 4, &dest_arg, &gateway_arg, &metric_arg, &ifname_arg) &&
-        !NCDVal_ListRead(i->args, 5, &dest_arg, &dest_prefix_arg, &gateway_arg, &metric_arg, &ifname_arg)
+    if (!NCDVal_ListRead(params->args, 4, &dest_arg, &gateway_arg, &metric_arg, &ifname_arg) &&
+        !NCDVal_ListRead(params->args, 5, &dest_arg, &dest_prefix_arg, &gateway_arg, &metric_arg, &ifname_arg)
     ) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;

+ 3 - 3
ncd/modules/net_ipv6_addr.c

@@ -56,7 +56,7 @@ struct instance {
     struct ipv6_ifaddr ifaddr;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -65,8 +65,8 @@ static void func_new (void *vo, NCDModuleInst *i)
     NCDValRef ifname_arg;
     NCDValRef addr_arg;
     NCDValRef prefix_arg = NCDVal_NewInvalid();
-    if (!NCDVal_ListRead(i->args, 2, &ifname_arg, &addr_arg) &&
-        !NCDVal_ListRead(i->args, 3, &ifname_arg, &addr_arg, &prefix_arg)
+    if (!NCDVal_ListRead(params->args, 2, &ifname_arg, &addr_arg) &&
+        !NCDVal_ListRead(params->args, 3, &ifname_arg, &addr_arg, &prefix_arg)
     ) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;

+ 7 - 7
ncd/modules/net_ipv6_addr_in_network.c

@@ -59,7 +59,7 @@ struct instance {
     int value;
 };
 
-static void func_new_common (void *vo, NCDModuleInst *i, int is_ifnot)
+static void func_new_common (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_ifnot)
 {
     struct instance *o = vo;
     o->i = i;
@@ -68,8 +68,8 @@ static void func_new_common (void *vo, NCDModuleInst *i, int is_ifnot)
     NCDValRef arg_addr;
     NCDValRef arg_net_addr;
     NCDValRef arg_net_prefix = NCDVal_NewInvalid();
-    if (!NCDVal_ListRead(i->args, 2, &arg_addr, &arg_net_addr) &&
-        !NCDVal_ListRead(i->args, 3, &arg_addr, &arg_net_addr, &arg_net_prefix) 
+    if (!NCDVal_ListRead(params->args, 2, &arg_addr, &arg_net_addr) &&
+        !NCDVal_ListRead(params->args, 3, &arg_addr, &arg_net_addr, &arg_net_prefix) 
     ) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
@@ -125,14 +125,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_normal (void *vo, NCDModuleInst *i)
+static void func_new_normal (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_common(vo, i, 0);
+    func_new_common(vo, i, params, 0);
 }
 
-static void func_new_ifnot (void *vo, NCDModuleInst *i)
+static void func_new_ifnot (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_common(vo, i, 1);
+    func_new_common(vo, i, params, 1);
 }
 
 static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *out)

+ 3 - 3
ncd/modules/net_ipv6_route.c

@@ -68,7 +68,7 @@ struct instance {
     const char *ifname;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -79,8 +79,8 @@ static void func_new (void *vo, NCDModuleInst *i)
     NCDValRef gateway_arg;
     NCDValRef metric_arg;
     NCDValRef ifname_arg;
-    if (!NCDVal_ListRead(i->args, 4, &dest_arg, &gateway_arg, &metric_arg, &ifname_arg) &&
-        !NCDVal_ListRead(i->args, 5, &dest_arg, &dest_prefix_arg, &gateway_arg, &metric_arg, &ifname_arg)
+    if (!NCDVal_ListRead(params->args, 4, &dest_arg, &gateway_arg, &metric_arg, &ifname_arg) &&
+        !NCDVal_ListRead(params->args, 5, &dest_arg, &dest_prefix_arg, &gateway_arg, &metric_arg, &ifname_arg)
     ) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;

+ 2 - 2
ncd/modules/net_ipv6_wait_dynamic_addr.c

@@ -92,14 +92,14 @@ static void monitor_handler_error (struct instance *o)
     instance_free(o);
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef ifname_arg;
-    if (!NCDVal_ListRead(i->args, 1, &ifname_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &ifname_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_up.c

@@ -49,14 +49,14 @@ struct instance {
     const char *ifname;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef ifname_arg;
-    if (!NCDVal_ListRead(o->i->args, 1, &ifname_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &ifname_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 5 - 5
ncd/modules/net_watch_interfaces.c

@@ -344,13 +344,13 @@ out:
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
-    if (!NCDVal_ListRead(o->i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -421,16 +421,16 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return event_template_getvar(&o->templ, name, mem, out);
 }
 
-static void nextevent_func_new (void *unused, NCDModuleInst *i)
+static void nextevent_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // make sure we are currently reporting an event
     if (!event_template_is_enabled(&mo->templ)) {

+ 6 - 6
ncd/modules/netmask.c

@@ -84,11 +84,11 @@ static void addr_func_init_templ (void *vo, NCDModuleInst *i, uint32_t addr)
     NCDModuleInst_Backend_Up(i);
 }
 
-static void prefix_to_mask_func_init (void *vo, NCDModuleInst *i)
+static void prefix_to_mask_func_init (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef prefix_arg;
-    if (!NCDVal_ListRead(i->args, 1, &prefix_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &prefix_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -115,12 +115,12 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void ipv4_net_from_addr_and_prefix_func_init (void *vo, NCDModuleInst *i)
+static void ipv4_net_from_addr_and_prefix_func_init (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef addr_arg;
     NCDValRef prefix_arg;
-    if (!NCDVal_ListRead(i->args, 2, &addr_arg, &prefix_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &addr_arg, &prefix_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -179,14 +179,14 @@ static int addr_func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValR
     return 0;
 }
 
-static void mask_to_prefix_func_init (void *vo, NCDModuleInst *i)
+static void mask_to_prefix_func_init (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct prefix_instance *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef mask_arg;
-    if (!NCDVal_ListRead(i->args, 1, &mask_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &mask_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 5 - 5
ncd/modules/ondemand.c

@@ -208,7 +208,7 @@ static void ondemand_process_handler (struct ondemand *o, int event)
     }
 }
 
-static void ondemand_func_new (void *vo, NCDModuleInst *i)
+static void ondemand_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct ondemand *o = vo;
     o->i = i;
@@ -216,7 +216,7 @@ static void ondemand_func_new (void *vo, NCDModuleInst *i)
     // read arguments
     NCDValRef arg_template_name;
     NCDValRef arg_args;
-    if (!NCDVal_ListRead(i->args, 2, &arg_template_name, &arg_args)) {
+    if (!NCDVal_ListRead(params->args, 2, &arg_template_name, &arg_args)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -279,19 +279,19 @@ static void ondemand_func_die (void *vo)
     }
 }
 
-static void demand_func_new (void *vo, NCDModuleInst *i)
+static void demand_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct demand *o = vo;
     o->i = i;
     
     // read arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // set ondemand
-    o->od = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    o->od = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // add to ondemand's demands list
     LinkedList1_Append(&o->od->demands_list, &o->demands_list_node);

+ 10 - 10
ncd/modules/parse.c

@@ -126,14 +126,14 @@ static int parse_ipv4_addr (NCDModuleInst *i, const char *str, NCDValMem *mem, N
     return 1;
 }
 
-static void new_templ (void *vo, NCDModuleInst *i, parse_func pfunc)
+static void new_templ (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, parse_func pfunc)
 {
     struct instance *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef str_arg;
-    if (!NCDVal_ListRead(i->args, 1, &str_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &str_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -196,28 +196,28 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return 0;
 }
 
-static void func_new_parse_number (void *vo, NCDModuleInst *i)
+static void func_new_parse_number (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, parse_number);
+    new_templ(vo, i, params, parse_number);
 }
 
-static void func_new_parse_value (void *vo, NCDModuleInst *i)
+static void func_new_parse_value (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, parse_value);
+    new_templ(vo, i, params, parse_value);
 }
 
-static void func_new_parse_ipv4_addr (void *vo, NCDModuleInst *i)
+static void func_new_parse_ipv4_addr (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, parse_ipv4_addr);
+    new_templ(vo, i, params, parse_ipv4_addr);
 }
 
-static void ipv4_cidr_addr_func_new (void *vo, NCDModuleInst *i)
+static void ipv4_cidr_addr_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct ipv4_cidr_instance *o = vo;
     o->i = i;
     
     NCDValRef str_arg;
-    if (!NCDVal_ListRead(i->args, 1, &str_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &str_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 21 - 19
ncd/modules/print.c

@@ -62,15 +62,16 @@
 
 struct rprint_instance {
     NCDModuleInst *i;
+    NCDValRef args;
     int ln;
 };
 
-static int check_args (NCDModuleInst *i)
+static int check_args (NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    size_t num_args = NCDVal_ListCount(i->args);
+    size_t num_args = NCDVal_ListCount(params->args);
     
     for (size_t j = 0; j < num_args; j++) {
-        NCDValRef arg = NCDVal_ListGet(i->args, j);
+        NCDValRef arg = NCDVal_ListGet(params->args, j);
         if (!NCDVal_IsString(arg)) {
             ModuleLog(i, BLOG_ERROR, "wrong type");
             return 0;
@@ -80,12 +81,12 @@ static int check_args (NCDModuleInst *i)
     return 1;
 }
 
-static void do_print (NCDModuleInst *i, int ln)
+static void do_print (NCDModuleInst *i, NCDValRef args, int ln)
 {
-    size_t num_args = NCDVal_ListCount(i->args);
+    size_t num_args = NCDVal_ListCount(args);
     
     for (size_t j = 0; j < num_args; j++) {
-        NCDValRef arg = NCDVal_ListGet(i->args, j);
+        NCDValRef arg = NCDVal_ListGet(args, j);
         ASSERT(NCDVal_IsString(arg))
         
         const char *str = NCDVal_StringValue(arg);
@@ -108,13 +109,14 @@ static void do_print (NCDModuleInst *i, int ln)
     }
 }
 
-static void rprint_func_new_common (void *vo, NCDModuleInst *i, int ln)
+static void rprint_func_new_common (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int ln)
 {
     struct rprint_instance *o = vo;
     o->i = i;
+    o->args = params->args;
     o->ln = ln;
     
-    if (!check_args(i)) {
+    if (!check_args(i, params)) {
         goto fail0;
     }
     
@@ -130,18 +132,18 @@ static void rprint_func_die (void *vo)
 {
     struct rprint_instance *o = vo;
     
-    do_print(o->i, o->ln);
+    do_print(o->i, o->args, o->ln);
     
     NCDModuleInst_Backend_Dead(o->i);
 }
 
-static void print_func_new (void *unused, NCDModuleInst *i)
+static void print_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    if (!check_args(i)) {
+    if (!check_args(i, params)) {
         goto fail0;
     }
     
-    do_print(i, 0);
+    do_print(i, params->args, 0);
     
     NCDModuleInst_Backend_Up(i);
     return;
@@ -151,13 +153,13 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void println_func_new (void *unused, NCDModuleInst *i)
+static void println_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    if (!check_args(i)) {
+    if (!check_args(i, params)) {
         goto fail0;
     }
     
-    do_print(i, 1);
+    do_print(i, params->args, 1);
     
     NCDModuleInst_Backend_Up(i);
     return;
@@ -167,14 +169,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void rprint_func_new (void *vo, NCDModuleInst *i)
+static void rprint_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    return rprint_func_new_common(vo, i, 0);
+    return rprint_func_new_common(vo, i, params, 0);
 }
 
-static void rprintln_func_new (void *vo, NCDModuleInst *i)
+static void rprintln_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    return rprint_func_new_common(vo, i, 1);
+    return rprint_func_new_common(vo, i, params, 1);
 }
 
 static const struct NCDModule modules[] = {

+ 8 - 8
ncd/modules/process_manager.c

@@ -415,13 +415,13 @@ int process_set_params (struct process *p, const char *template_name, NCDValMem
     return 1;
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
-    if (!NCDVal_ListRead(o->i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -472,13 +472,13 @@ static void func_die (void *vo)
     o->dying = 1;
 }
 
-static void start_func_new (void *unused, NCDModuleInst *i)
+static void start_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
     NCDValRef name_arg;
     NCDValRef template_name_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(i->args, 3, &name_arg, &template_name_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 3, &name_arg, &template_name_arg, &args_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -495,7 +495,7 @@ static void start_func_new (void *unused, NCDModuleInst *i)
     NCDModuleInst_Backend_Up(i);
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     if (mo->dying) {
         ModuleLog(i, BLOG_INFO, "manager is dying, not creating process %s", name);
@@ -525,11 +525,11 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void stop_func_new (void *unused, NCDModuleInst *i)
+static void stop_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
     NCDValRef name_arg;
-    if (!NCDVal_ListRead(i->args, 1, &name_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &name_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -544,7 +544,7 @@ static void stop_func_new (void *unused, NCDModuleInst *i)
     NCDModuleInst_Backend_Up(i);
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     if (mo->dying) {
         ModuleLog(i, BLOG_INFO, "manager is dying, not stopping process %s", name);

+ 4 - 4
ncd/modules/reboot.c

@@ -42,10 +42,10 @@
 
 #define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
 
-static void func_new_hard_reboot (void *unused, NCDModuleInst *i)
+static void func_new_hard_reboot (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -65,10 +65,10 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_hard_poweroff (void *unused, NCDModuleInst *i)
+static void func_new_hard_poweroff (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 10 - 10
ncd/modules/ref.c

@@ -67,13 +67,13 @@ struct ref_instance {
 
 static void ref_instance_free (struct ref_instance *o);
 
-static void refhere_func_new (void *vo, NCDModuleInst *i)
+static void refhere_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct refhere_instance *o = vo;
     o->i = i;
     
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -117,13 +117,13 @@ static int refhere_func_getobj (void *vo, const char *objname, NCDObject *out_ob
     return NCDModuleInst_Backend_GetObj(o->i, objname, out_object);
 }
 
-static void ref_func_new_templ (void *vo, NCDModuleInst *i, struct refhere_instance *rh)
+static void ref_func_new_templ (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, struct refhere_instance *rh)
 {
     struct ref_instance *o = vo;
     o->i = i;
     
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -143,18 +143,18 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void ref_func_new_from_refhere (void *vo, NCDModuleInst *i)
+static void ref_func_new_from_refhere (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    struct refhere_instance *rh = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct refhere_instance *rh = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
-    return ref_func_new_templ(vo, i, rh);
+    return ref_func_new_templ(vo, i, params, rh);
 }
 
-static void ref_func_new_from_ref (void *vo, NCDModuleInst *i)
+static void ref_func_new_from_ref (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    struct ref_instance *ref = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct ref_instance *ref = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
-    return ref_func_new_templ(vo, i, ref->rh);
+    return ref_func_new_templ(vo, i, params, ref->rh);
 }
 
 static void ref_instance_free (struct ref_instance *o)

+ 4 - 4
ncd/modules/regex_match.c

@@ -97,7 +97,7 @@ struct replace_instance {
     size_t output_len;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -105,7 +105,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // read arguments
     NCDValRef input_arg;
     NCDValRef regex_arg;
-    if (!NCDVal_ListRead(o->i->args, 2, &input_arg, &regex_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &input_arg, &regex_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -184,7 +184,7 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return 0;
 }
 
-static void replace_func_new (void *vo, NCDModuleInst *i)
+static void replace_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct replace_instance *o = vo;
     o->i = i;
@@ -193,7 +193,7 @@ static void replace_func_new (void *vo, NCDModuleInst *i)
     NCDValRef input_arg;
     NCDValRef regex_arg;
     NCDValRef replace_arg;
-    if (!NCDVal_ListRead(i->args, 3, &input_arg, &regex_arg, &replace_arg)) {
+    if (!NCDVal_ListRead(params->args, 3, &input_arg, &regex_arg, &replace_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }

+ 4 - 4
ncd/modules/run.c

@@ -57,12 +57,12 @@ struct instance {
     command_template_instance cti;
 };
 
-static int build_cmdline (NCDModuleInst *i, int remove, char **exec, CmdLine *cl)
+static int build_cmdline (NCDModuleInst *i, NCDValRef args, int remove, char **exec, CmdLine *cl)
 {
     // read arguments
     NCDValRef do_cmd_arg;
     NCDValRef undo_cmd_arg;
-    if (!NCDVal_ListRead(i->args, 2, &do_cmd_arg, &undo_cmd_arg)) {
+    if (!NCDVal_ListRead(args, 2, &do_cmd_arg, &undo_cmd_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -134,7 +134,7 @@ fail0:
     return 0;
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -142,7 +142,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // init dummy event lock
     BEventLock_Init(&o->lock, BReactor_PendingGroup(i->iparams->reactor));
     
-    command_template_new(&o->cti, i, build_cmdline, template_free_func, o, BLOG_CURRENT_CHANNEL, &o->lock);
+    command_template_new(&o->cti, i, params, build_cmdline, template_free_func, o, BLOG_CURRENT_CHANNEL, &o->lock);
     return;
 }
 

+ 8 - 8
ncd/modules/runonce.c

@@ -166,7 +166,7 @@ static void process_handler (struct instance *o, int normally, uint8_t normally_
     NCDModuleInst_Backend_Up(o->i);
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -177,7 +177,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // read arguments
     NCDValRef cmd_arg;
     NCDValRef opts_arg = NCDVal_NewInvalid();
-    if (!NCDVal_ListRead(i->args, 1, &cmd_arg) && !NCDVal_ListRead(i->args, 2, &cmd_arg, &opts_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &cmd_arg) && !NCDVal_ListRead(params->args, 2, &cmd_arg, &opts_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -242,14 +242,14 @@ static void func_new (void *vo, NCDModuleInst *i)
     fds[nfds] = -1;
     
     // build params
-    struct BProcess_params params;
-    params.username = NULL;
-    params.fds = fds;
-    params.fds_map = fds_map;
-    params.do_setsid = do_setsid;
+    struct BProcess_params p_params;
+    p_params.username = NULL;
+    p_params.fds = fds;
+    p_params.fds_map = fds_map;
+    p_params.do_setsid = do_setsid;
     
     // start process
-    if (!BProcess_Init2(&o->process, o->i->iparams->manager, (BProcess_handler)process_handler, o, exec, CmdLine_Get(&cl), params)) {
+    if (!BProcess_Init2(&o->process, o->i->iparams->manager, (BProcess_handler)process_handler, o, exec, CmdLine_Get(&cl), p_params)) {
         ModuleLog(i, BLOG_ERROR, "BProcess_Init failed");
         CmdLine_Free(&cl);
         free(exec);

+ 2 - 2
ncd/modules/sleep.c

@@ -68,7 +68,7 @@ static void timer_handler (void *vo)
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -76,7 +76,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // check arguments
     NCDValRef ms_start_arg;
     NCDValRef ms_stop_arg;
-    if (!NCDVal_ListRead(i->args, 2, &ms_start_arg, &ms_stop_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &ms_start_arg, &ms_stop_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 5 - 5
ncd/modules/spawn.c

@@ -202,7 +202,7 @@ static void continue_terminating (struct instance *o)
     o->state = STATE_TERMINATING;
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -210,7 +210,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // check arguments
     NCDValRef template_name_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(i->args, 2, &template_name_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &template_name_arg, &args_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -287,17 +287,17 @@ static void func_die (void *vo)
     }
 }
 
-static void join_func_new (void *vo, NCDModuleInst *i)
+static void join_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct join_instance *o = vo;
     o->i = i;
     
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    o->spawn = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    o->spawn = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     assert_dirty_state(o->spawn);
     
     LinkedList0_Prepend(&o->spawn->clean_list, &o->list_node);

+ 2 - 2
ncd/modules/strcmp.c

@@ -49,7 +49,7 @@ struct instance {
     int result;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -57,7 +57,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // check arguments
     NCDValRef str1_arg;
     NCDValRef str2_arg;
-    if (!NCDVal_ListRead(i->args, 2, &str1_arg, &str2_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &str1_arg, &str2_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 5 - 5
ncd/modules/sys_evdev.c

@@ -141,14 +141,14 @@ static void device_nextevent (struct instance *o)
     NCDModuleInst_Backend_Down(o->i);
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
     NCDValRef device_arg;
-    if (!NCDVal_ListRead(o->i->args, 1, &device_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &device_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -294,16 +294,16 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return 0;
 }
 
-static void nextevent_func_new (void *unused, NCDModuleInst *i)
+static void nextevent_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // make sure we are currently reporting an event
     if (!mo->processing) {

+ 5 - 5
ncd/modules/sys_request_client.c

@@ -529,14 +529,14 @@ bad:
     return 0;
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
     NCDValRef connect_addr_arg;
-    if (!NCDVal_ListRead(i->args, 1, &connect_addr_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &connect_addr_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -592,7 +592,7 @@ static void func_die (void *vo)
     instance_free(o, 0);
 }
 
-static void request_func_new (void *vo, NCDModuleInst *i)
+static void request_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct request_instance *o = vo;
     o->i = i;
@@ -602,7 +602,7 @@ static void request_func_new (void *vo, NCDModuleInst *i)
     NCDValRef reply_handler_arg;
     NCDValRef finished_handler_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(i->args, 4, &request_data_arg, &reply_handler_arg, &finished_handler_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 4, &request_data_arg, &reply_handler_arg, &finished_handler_arg, &args_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -617,7 +617,7 @@ static void request_func_new (void *vo, NCDModuleInst *i)
     o->args = args_arg;
     
     // get client
-    struct instance *client = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *client = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     o->client = client;
     
     // check client state

+ 8 - 8
ncd/modules/sys_request_server.c

@@ -725,7 +725,7 @@ bad:
     return 0;
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -734,7 +734,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     NCDValRef listen_addr_arg;
     NCDValRef request_handler_template_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(i->args, 3, &listen_addr_arg, &request_handler_template_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 3, &listen_addr_arg, &request_handler_template_arg, &args_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -809,17 +809,17 @@ static void func_die (void *vo)
     }
 }
 
-static void reply_func_new (void *unused, NCDModuleInst *i)
+static void reply_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef reply_data;
-    if (!NCDVal_ListRead(i->args, 1, &reply_data)) {
+    if (!NCDVal_ListRead(params->args, 1, &reply_data)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail;
     }
     
     NCDModuleInst_Backend_Up(i);
     
-    struct request *r = i->method_user;
+    struct request *r = params->method_user;
     struct connection *c = r->con;
     
     if (r->terminating) {
@@ -841,16 +841,16 @@ fail:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void finish_func_new (void *unused, NCDModuleInst *i)
+static void finish_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail;
     }
     
     NCDModuleInst_Backend_Up(i);
     
-    struct request *r = i->method_user;
+    struct request *r = params->method_user;
     
     if (r->terminating) {
         ModuleLog(i, BLOG_ERROR, "request is dying, cannot submit finished");

+ 5 - 5
ncd/modules/sys_watch_directory.c

@@ -235,14 +235,14 @@ static void next_event (struct instance *o)
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
     NCDValRef dir_arg;
-    if (!NCDVal_ListRead(o->i->args, 1, &dir_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &dir_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -374,16 +374,16 @@ fail:
     return 1;
 }
 
-static void nextevent_func_new (void *unused, NCDModuleInst *i)
+static void nextevent_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // make sure we are currently reporting an event
     if (!mo->processing) {

+ 5 - 5
ncd/modules/sys_watch_input.c

@@ -342,14 +342,14 @@ out:
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
     NCDValRef devnode_type_arg;
-    if (!NCDVal_ListRead(o->i->args, 1, &devnode_type_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &devnode_type_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -400,16 +400,16 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return event_template_getvar(&o->templ, name, mem, out);
 }
 
-static void nextevent_func_new (void *unused, NCDModuleInst *i)
+static void nextevent_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // make sure we are currently reporting an event
     if (!event_template_is_enabled(&mo->templ)) {

+ 5 - 5
ncd/modules/sys_watch_usb.c

@@ -317,13 +317,13 @@ out:
     }
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -368,16 +368,16 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return event_template_getvar(&o->templ, name, mem, out);
 }
 
-static void nextevent_func_new (void *unused, NCDModuleInst *i)
+static void nextevent_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // make sure we are currently reporting an event
     if (!event_template_is_enabled(&mo->templ)) {

+ 2 - 2
ncd/modules/to_string.c

@@ -49,14 +49,14 @@ struct instance {
     char *str;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // read arguments
     NCDValRef value_arg;
-    if (!NCDVal_ListRead(i->args, 1, &value_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &value_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }

+ 5 - 5
ncd/modules/try.c

@@ -156,7 +156,7 @@ static void start_terminating (struct instance *o)
     o->state = STATE_DEINIT;
 }
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
@@ -164,7 +164,7 @@ static void func_new (void *vo, NCDModuleInst *i)
     // check arguments
     NCDValRef template_name_arg;
     NCDValRef args_arg;
-    if (!NCDVal_ListRead(i->args, 2, &template_name_arg, &args_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &template_name_arg, &args_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -238,11 +238,11 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return 0;
 }
 
-static void assert_func_new (void *unused, NCDModuleInst *i)
+static void assert_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments
     NCDValRef cond_arg;
-    if (!NCDVal_ListRead(i->args, 1, &cond_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &cond_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
@@ -252,7 +252,7 @@ static void assert_func_new (void *unused, NCDModuleInst *i)
     }
     
     // get instance
-    struct instance *mo = i->method_user;
+    struct instance *mo = params->method_user;
     ASSERT(mo->state == STATE_INIT || mo->state == STATE_DEINIT)
     
     // signal up

+ 44 - 44
ncd/modules/value.c

@@ -1016,10 +1016,10 @@ fail:
     return 1;
 }
 
-static void func_new_value (void *vo, NCDModuleInst *i)
+static void func_new_value (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef value_arg;
-    if (!NCDVal_ListRead(i->args, 1, &value_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &value_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -1037,15 +1037,15 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_get (void *vo, NCDModuleInst *i)
+static void func_new_get (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef where_arg;
-    if (!NCDVal_ListRead(i->args, 1, &where_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &where_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1066,15 +1066,15 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_try_get (void *vo, NCDModuleInst *i)
+static void func_new_try_get (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef where_arg;
-    if (!NCDVal_ListRead(i->args, 1, &where_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &where_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1092,10 +1092,10 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_getpath (void *vo, NCDModuleInst *i)
+static void func_new_getpath (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef path_arg;
-    if (!NCDVal_ListRead(i->args, 1, &path_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &path_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -1104,7 +1104,7 @@ static void func_new_getpath (void *vo, NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1125,16 +1125,16 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_insert_replace_common (void *vo, NCDModuleInst *i, int is_replace)
+static void func_new_insert_replace_common (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_replace)
 {
     NCDValRef where_arg;
     NCDValRef what_arg;
-    if (!NCDVal_ListRead(i->args, 2, &where_arg, &what_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &where_arg, &what_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1155,14 +1155,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_insert (void *vo, NCDModuleInst *i)
+static void func_new_insert (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_insert_replace_common(vo, i, 0);
+    func_new_insert_replace_common(vo, i, params, 0);
 }
 
-static void func_new_replace (void *vo, NCDModuleInst *i)
+static void func_new_replace (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_insert_replace_common(vo, i, 1);
+    func_new_insert_replace_common(vo, i, params, 1);
 }
 
 struct insert_undo_deinit_data {
@@ -1211,16 +1211,16 @@ static void undo_deinit_func (struct insert_undo_deinit_data *data, NCDModuleIns
     free(data);
 }
 
-static void func_new_insert_replace_undo_common (void *vo, NCDModuleInst *i, int is_replace)
+static void func_new_insert_replace_undo_common (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_replace)
 {
     NCDValRef where_arg;
     NCDValRef what_arg;
-    if (!NCDVal_ListRead(i->args, 2, &where_arg, &what_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &where_arg, &what_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1253,25 +1253,25 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_insert_undo (void *vo, NCDModuleInst *i)
+static void func_new_insert_undo (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_insert_replace_undo_common(vo, i, 0);
+    func_new_insert_replace_undo_common(vo, i, params, 0);
 }
 
-static void func_new_replace_undo (void *vo, NCDModuleInst *i)
+static void func_new_replace_undo (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    func_new_insert_replace_undo_common(vo, i, 1);
+    func_new_insert_replace_undo_common(vo, i, params, 1);
 }
 
-static void func_new_replace_this (void *vo, NCDModuleInst *i)
+static void func_new_replace_this (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef value_arg;
-    if (!NCDVal_ListRead(i->args, 1, &value_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &value_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1317,15 +1317,15 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_replace_this_undo (void *vo, NCDModuleInst *i)
+static void func_new_replace_this_undo (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef value_arg;
-    if (!NCDVal_ListRead(i->args, 1, &value_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &value_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1380,12 +1380,12 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void func_new_substr (void *vo, NCDModuleInst *i)
+static void func_new_substr (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef start_arg;
     NCDValRef length_arg = NCDVal_NewInvalid();
-    if (!NCDVal_ListRead(i->args, 1, &start_arg) &&
-        !NCDVal_ListRead(i->args, 2, &start_arg, &length_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &start_arg) &&
+        !NCDVal_ListRead(params->args, 2, &start_arg, &length_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -1406,7 +1406,7 @@ static void func_new_substr (void *vo, NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1440,15 +1440,15 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void remove_func_new (void *unused, NCDModuleInst *i)
+static void remove_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef where_arg;
-    if (!NCDVal_ListRead(i->args, 1, &where_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &where_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1468,14 +1468,14 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void delete_func_new (void *unused, NCDModuleInst *i)
+static void delete_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    if (!NCDVal_ListRead(i->args, 0)) {
+    if (!NCDVal_ListRead(params->args, 0)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1493,15 +1493,15 @@ fail0:
     NCDModuleInst_Backend_Dead(i);
 }
 
-static void reset_func_new (void *unused, NCDModuleInst *i)
+static void reset_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     NCDValRef what_arg;
-    if (!NCDVal_ListRead(i->args, 1, &what_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &what_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // build value from argument
     struct value *newv = value_init_fromvalue(i, what_arg);

+ 14 - 14
ncd/modules/valuemetic.c

@@ -100,14 +100,14 @@ static int compute_different (NCDValRef v1, NCDValRef v2)
     return NCDVal_Compare(v1, v2) != 0;
 }
 
-static void new_templ (void *vo, NCDModuleInst *i, compute_func cfunc)
+static void new_templ (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params, compute_func cfunc)
 {
     struct instance *o = vo;
     o->i = i;
     
     NCDValRef v1_arg;
     NCDValRef v2_arg;
-    if (!NCDVal_ListRead(i->args, 2, &v1_arg, &v2_arg)) {
+    if (!NCDVal_ListRead(params->args, 2, &v1_arg, &v2_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -146,34 +146,34 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return 0;
 }
 
-static void func_new_lesser (void *vo, NCDModuleInst *i)
+static void func_new_lesser (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_lesser);
+    new_templ(vo, i, params, compute_lesser);
 }
 
-static void func_new_greater (void *vo, NCDModuleInst *i)
+static void func_new_greater (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_greater);
+    new_templ(vo, i, params, compute_greater);
 }
 
-static void func_new_lesser_equal (void *vo, NCDModuleInst *i)
+static void func_new_lesser_equal (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_lesser_equal);
+    new_templ(vo, i, params, compute_lesser_equal);
 }
 
-static void func_new_greater_equal (void *vo, NCDModuleInst *i)
+static void func_new_greater_equal (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_greater_equal);
+    new_templ(vo, i, params, compute_greater_equal);
 }
 
-static void func_new_equal (void *vo, NCDModuleInst *i)
+static void func_new_equal (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_equal);
+    new_templ(vo, i, params, compute_equal);
 }
 
-static void func_new_different (void *vo, NCDModuleInst *i)
+static void func_new_different (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
-    new_templ(vo, i, compute_different);
+    new_templ(vo, i, params, compute_different);
 }
 
 static const struct NCDModule modules[] = {

+ 5 - 5
ncd/modules/var.c

@@ -52,14 +52,14 @@ struct instance {
     NCDValRef value;
 };
 
-static void func_new (void *vo, NCDModuleInst *i)
+static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     struct instance *o = vo;
     o->i = i;
     
     // read argument
     NCDValRef value_arg;
-    if (!NCDVal_ListRead(i->args, 1, &value_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &value_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
@@ -110,17 +110,17 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     return 0;
 }
 
-static void set_func_new (void *unused, NCDModuleInst *i)
+static void set_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // read arguments
     NCDValRef value_arg;
-    if (!NCDVal_ListRead(i->args, 1, &value_arg)) {
+    if (!NCDVal_ListRead(params->args, 1, &value_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
     
     // get method object
-    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
     
     // allocate new mem
     NCDValMem mem;