RPA Toolkit
Work on rmap_t - 2
[rpatk.git] / rlib / robject.h
1 #ifndef _ROBJECT_H_
2 #define _ROBJECT_H_
3
4 #include "rtypes.h"
5 #include "rlist.h"
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11
12 #define R_OBJECT_UNKNOWN 0
13 #define R_OBJECT_STRING 1
14 #define R_OBJECT_ARRAY 2
15 #define R_OBJECT_HARRAY 3
16 #define R_OBJECT_CARRAY 4
17 #define R_OBJECT_MAP 5
18 #define R_OBJECT_HASH 6
19 #define R_OBJECT_REF 7
20 #define R_OBJECT_JSOBJECT 8
21 #define R_OBJECT_GC 9
22 #define R_OBJECT_USER 256
23
24
25 typedef struct robject_s robject_t;
26 /*
27  * This should be renamed to cleanup
28  */
29 typedef void (*r_object_cleanupfun)(robject_t *ptr);
30 typedef robject_t* (*r_object_copyfun)(const robject_t *ptr);
31
32 struct robject_s {
33         rlink_t lnk;
34         rpointer *gc;
35         ruint32 type;
36         ruint32 size;
37         r_object_cleanupfun cleanup;
38         r_object_copyfun copy;
39 };
40
41 robject_t *r_object_create(rsize_t size);
42 robject_t *r_object_copy(const robject_t *obj);
43 void r_object_destroy(robject_t *obj);
44 void r_object_cleanup(robject_t *obj);
45 void r_object_init(robject_t *obj, ruint32 type, r_object_cleanupfun cleanup, r_object_copyfun copy);
46 void r_object_typeset(robject_t *obj, ruint32 type);
47 ruint32 r_object_typeget(robject_t *obj);
48
49 /*
50  * Virtual methods
51  */
52 robject_t *r_object_v_copy(const robject_t *obj);
53 void r_object_v_cleanup(robject_t *obj);
54
55 #ifdef __cplusplus
56 }
57 #endif
58
59 #endif