Mercurial > repos > tabletprog
view runtime/object.h @ 37:a6bf4869fcbe
Small refactor of built-in int32 type and added support for more operators on said type
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 10 Jul 2012 22:09:21 -0700 |
parents | bf5e88f6419d |
children | e7be612fd3ae |
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, ...) (((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); #endif //OBJECT_H_