comparison runtime/object.h @ 266:75dc7161c1ca

Added object module which provides some basic reflection capabilities
author Michael Pavone <pavone@retrodev.com>
date Thu, 17 Jul 2014 23:57:41 -0700
parents 18598163e3ef
children d2b70cba661e
comparison
equal deleted inserted replaced
265:d6a4c9e7716e 266:75dc7161c1ca
1 #ifndef OBJECT_H_ 1 #ifndef OBJECT_H_
2 #define OBJECT_H_ 2 #define OBJECT_H_
3 3
4 #include <stdint.h> 4 #include <stdint.h>
5 #include <stdarg.h> 5 #include <stdarg.h>
6
7 #define LAST_METHOD 0xFFFFFFFF
6 8
7 typedef struct obj_meta obj_meta; 9 typedef struct obj_meta obj_meta;
8 10
9 typedef struct object 11 typedef struct object
10 { 12 {
25 */ 27 */
26 struct obj_meta 28 struct obj_meta
27 { 29 {
28 uint32_t size; 30 uint32_t size;
29 method meth_lookup[16]; 31 method meth_lookup[16];
32 uint32_t *methods[16];
30 }; 33 };
31 34
32 extern obj_meta lambda_meta; 35 extern obj_meta lambda_meta;
33 36
34 object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...); 37 object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...);
36 39
37 object * make_object(obj_meta * meta, void * parent, int num_props, ...); 40 object * make_object(obj_meta * meta, void * parent, int num_props, ...);
38 object * make_lambda(void * env, closure_func func); 41 object * make_lambda(void * env, closure_func func);
39 object * make_array(uint32_t num_els, ...); 42 object * make_array(uint32_t num_els, ...);
40 object * make_list(uint32_t num_els, ...); 43 object * make_list(uint32_t num_els, ...);
44 int object_understands(object * obj, uint32_t method_id);
41 45
42 #endif //OBJECT_H_ 46 #endif //OBJECT_H_