comparison runtime/object.h @ 186:ba35ab624ec2

Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
author Mike Pavone <pavone@retrodev.com>
date Fri, 07 Oct 2011 00:10:02 -0700
parents 9fab36cc706b
children
comparison
equal deleted inserted replaced
185:4580c08fd4e8 186:ba35ab624ec2
30 int32_t size; 30 int32_t size;
31 int32_t boxed_size; 31 int32_t boxed_size;
32 } blueprint; 32 } blueprint;
33 33
34 struct object { 34 struct object {
35 #ifndef USE_GC
35 rh_atomic32(refcount); 36 rh_atomic32(refcount);
37 #endif
36 blueprint *bprint; 38 blueprint *bprint;
37 }; 39 };
38 40
39 typedef struct { 41 typedef struct {
40 object base; 42 object base;
64 #define MObject(name) } nt_ ## name; typedef struct { multisize SP_header; nt_ ## name payload; } t_ ## name; 66 #define MObject(name) } nt_ ## name; typedef struct { multisize SP_header; nt_ ## name payload; } t_ ## name;
65 #define Box(nakedtype,fieldname,objectname) typedef struct{ object SP_header; nakedtype fieldname; } t_ ## objectname; 67 #define Box(nakedtype,fieldname,objectname) typedef struct{ object SP_header; nakedtype fieldname; } t_ ## objectname;
66 68
67 #define get_blueprint(object) (object)->bprint 69 #define get_blueprint(object) (object)->bprint
68 70
71 #ifdef USE_GC
72 #define add_ref(object) object
73 #define release_ref(object)
74 #else
69 #define add_ref(object) (rh_atomic_add((object), refcount, 1),object) 75 #define add_ref(object) (rh_atomic_add((object), refcount, 1),object)
76 void release_ref(object * obj);
77 #endif
70 78
71 returntype call_method(uint32_t methodid, calldata * params); 79 /*returntype call_method(uint32_t methodid, calldata * params);
72 returntype set_field(uint32_t setfieldid, calldata * params); 80 returntype set_field(uint32_t setfieldid, calldata * params);
73 returntype get_field(uint32_t getfieldid, calldata * params); 81 returntype get_field(uint32_t getfieldid, calldata * params);*/
74 object * alloc_object(blueprint * bp); 82 object * alloc_object(blueprint * bp);
75 void * alloc_variable(uint32_t size); 83 void * alloc_variable(uint32_t size);
76 object * new_object(uint32_t type); 84 object * new_object(uint32_t type);
77 object * new_object_bp(blueprint * bp); 85 object * new_object_bp(blueprint * bp);
78 multisize * new_multisize(uint32_t type, uint32_t size); 86 multisize * new_multisize(uint32_t type, uint32_t size);
79 void release_ref(object * obj);
80 blueprint * register_type_byid(uint32_t type, int32_t size, special_func init, special_func copy, special_func cleanup); 87 blueprint * register_type_byid(uint32_t type, int32_t size, special_func init, special_func copy, special_func cleanup);
81 blueprint * register_type(int32_t size, special_func init, special_func copy, special_func cleanup); 88 blueprint * register_type(int32_t size, special_func init, special_func copy, special_func cleanup);
82 blueprint * new_blueprint(uint32_t type, int32_t size, special_func init, special_func copy, special_func cleanup); 89 blueprint * new_blueprint(uint32_t type, int32_t size, special_func init, special_func copy, special_func cleanup);
83 void add_method(blueprint * bp, uint32_t methodid, rhope_func impl); 90 void add_method(blueprint * bp, uint32_t methodid, rhope_func impl);
84 void add_getter(blueprint * bp, uint32_t fieldid, rhope_func impl); 91 void add_getter(blueprint * bp, uint32_t fieldid, rhope_func impl);
85 void add_setter(blueprint * bp, uint32_t fieldid, rhope_func impl); 92 void add_setter(blueprint * bp, uint32_t fieldid, rhope_func impl);
86 returntype convert_to(uint32_t convertto, calldata * params); 93 /*returntype convert_to(uint32_t convertto, calldata * params);
87 returntype convert_from(uint32_t convertfrom, calldata * params); 94 returntype convert_from(uint32_t convertfrom, calldata * params);*/
88 object * copy_object(object * tocopy); 95 object * copy_object(object * tocopy);
89 object * naked_to_boxed(uint32_t type, void * rawdata); 96 object * naked_to_boxed(uint32_t type, void * rawdata);
90 void boxed_to_naked(object * src, void * dest); 97 void boxed_to_naked(object * src, void * dest);
91 returntype coerce_value(uint32_t type, calldata * params); 98 /*returntype coerce_value(uint32_t type, calldata * params);*/
92 blueprint * get_blueprint_byid(uint32_t type); 99 blueprint * get_blueprint_byid(uint32_t type);
93 100
94 extern blueprint ** registered_types; 101 extern blueprint ** registered_types;
95 extern uint32_t max_registered_type; 102 extern uint32_t max_registered_type;
96 #include "fixed_alloc.h" 103 #include "fixed_alloc.h"