Mercurial > repos > tabletprog
view runtime/object.h @ 69:ba032565c7a5
Fix handling of variable style access to self and parent object messages defined with lambdas. Improve test case for this bug to include parent object access as well as self object access.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 14 Jul 2012 19:24:04 -0700 |
parents | 2a9c6eed0c70 |
children | 18598163e3ef |
line wrap: on
line source
#ifndef OBJECT_H_ #define OBJECT_H_ #include <stdint.h> #include <stdarg.h> typedef struct obj_meta obj_meta; typedef struct object { obj_meta * meta; struct object * parent; } object; typedef object * (*method)(uint32_t method_id, uint32_t num_args, object * self, va_list args); typedef object * (*closure_func)(void *, uint32_t, ...); /* typedef struct closure { object header; void * env; closure_func func; } closure; */ struct obj_meta { uint32_t size; method meth_lookup[16]; }; extern obj_meta lambda_meta; object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...); #define ccall(clos, num_args, ...) (((lambda *)clos)->func(((lambda *)clos)->env, num_args,##__VA_ARGS__)) object * make_object(obj_meta * meta, void * parent, int num_props, ...); object * make_lambda(void * env, closure_func func); object * make_array(uint32_t num_els, ...); #endif //OBJECT_H_