Mercurial > repos > tabletprog
diff runtime/object.h @ 35:bf5e88f6419d
Use a function/method call strategy that actually works
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 09 Jul 2012 21:32:28 -0700 |
parents | a10f1b049193 |
children | e7be612fd3ae |
line wrap: on
line diff
--- a/runtime/object.h Mon Jul 09 08:57:50 2012 -0700 +++ b/runtime/object.h Mon Jul 09 21:32:28 2012 -0700 @@ -2,6 +2,7 @@ #define OBJECT_H_ #include <stdint.h> +#include <stdarg.h> typedef struct obj_meta obj_meta; @@ -11,9 +12,9 @@ struct object * parent; } object; -typedef object * (*method)(uint32_t method_id, uint32_t num_args, object **); +typedef object * (*method)(uint32_t method_id, uint32_t num_args, object * self, va_list args); -typedef object * (*closure_func)(void *, uint32_t, object **); +typedef object * (*closure_func)(void *, uint32_t, ...); typedef struct closure { @@ -30,8 +31,8 @@ extern obj_meta lambda_meta; -#define mcall(method_id, num_args, args) (args[0])->meta->meth_lookup[method_id & 0xF](method_id, num_args, args) -#define ccall(clos, num_args, args) (((closure *)clos)->func(((closure *)clos)->env, num_args, args)) +object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...); +#define ccall(clos, num_args, ...) (((closure *)clos)->func(((closure *)clos)->env, num_args,##__VA_ARGS__)) object * make_object(obj_meta * meta, void * parent, int num_props, ...); object * make_closure(void * env, closure_func func);