summaryrefslogtreecommitdiffstatshomepage
path: root/py/objfun.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-13 19:50:05 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-13 19:50:05 +0000
commitf62d33aa1dc5afad9abbaf257531bdc4b0fbfdc0 (patch)
treec512ba2f387febe7fa57c2e1bf52b6250d579e73 /py/objfun.c
parentf88a72a88e78ce1cfbd25f0cbf1fbff5e6fd43cb (diff)
downloadmicropython-f62d33aa1dc5afad9abbaf257531bdc4b0fbfdc0.tar.gz
micropython-f62d33aa1dc5afad9abbaf257531bdc4b0fbfdc0.zip
Consolidate rt_make_function_[0123] to rt_make_function_n.
Diffstat (limited to 'py/objfun.c')
-rw-r--r--py/objfun.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/py/objfun.c b/py/objfun.c
index b8ebce7a39..ba3ce6279f 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -98,42 +98,13 @@ const mp_obj_type_t fun_native_type = {
.call_n_kw = fun_native_call_n_kw,
};
-mp_obj_t rt_make_function_0(mp_fun_0_t fun) {
+// fun must have the correct signature for n_args fixed arguments
+mp_obj_t rt_make_function_n(int n_args, void *fun) {
mp_obj_fun_native_t *o = m_new_obj(mp_obj_fun_native_t);
o->base.type = &fun_native_type;
o->is_kw = false;
- o->n_args_min = 0;
- o->n_args_max = 0;
- o->fun = fun;
- return o;
-}
-
-mp_obj_t rt_make_function_1(mp_fun_1_t fun) {
- mp_obj_fun_native_t *o = m_new_obj(mp_obj_fun_native_t);
- o->base.type = &fun_native_type;
- o->is_kw = false;
- o->n_args_min = 1;
- o->n_args_max = 1;
- o->fun = fun;
- return o;
-}
-
-mp_obj_t rt_make_function_2(mp_fun_2_t fun) {
- mp_obj_fun_native_t *o = m_new_obj(mp_obj_fun_native_t);
- o->base.type = &fun_native_type;
- o->is_kw = false;
- o->n_args_min = 2;
- o->n_args_max = 2;
- o->fun = fun;
- return o;
-}
-
-mp_obj_t rt_make_function_3(mp_fun_3_t fun) {
- mp_obj_fun_native_t *o = m_new_obj(mp_obj_fun_native_t);
- o->base.type = &fun_native_type;
- o->is_kw = false;
- o->n_args_min = 3;
- o->n_args_max = 3;
+ o->n_args_min = n_args;
+ o->n_args_max = n_args;
o->fun = fun;
return o;
}