ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
mtree.h
Go to the documentation of this file.
1 
12 #ifndef _CEPTR_MTREE_H
13 #define _CEPTR_MTREE_H
14 
15 #include <string.h>
16 #include <stdlib.h>
17 #include "ceptr_error.h"
18 #include "sys_defs.h"
19 #include "ceptr_types.h"
20 
21 typedef struct MwalkState {
22  Mindex i;
23  union {
24  Mindex pi;
25  T *t;
26  } user;
27 } MwalkState;
28 
29 H __m_new(H parent,Symbol symbol,void *surface,size_t size,uint32_t flags);
30 #define _m_new(parent,symbol,surface,size) __m_new(parent,symbol,surface,size,0)
31 #define _m_newt(parent,symbol,h) __m_new(parent,symbol,&(h),sizeof(H),TFLAG_SURFACE_IS_TREE)
32 
33 H _m_newi(H h,Symbol symbol,int surface);
34 H _m_new_from_t(T *t);
35 T *_t_new_from_m(H h);
36 N *__m_get(H h);
37 size_t _m_size(H h);
38 #define _m_free(h) __m_free(h,1)
39 void __m_free(H h,int free_surface);
40 int _m_children(H h);
41 void * _m_surface(H h);
42 Maddr _m_parent(H h);
43 Maddr _m_child(H h,Mindex i);
44 Symbol _m_symbol(H h);
47 H _m_newr(H parent,Symbol s);
48 H _m_add(H parent,H h);
49 H _m_detatch(H h);
50 S * _m_serialize(M *m);
51 H _m_unserialize(S *);
52 
53 void _m_walk(H h,void (*walkfn)(H ,N *,void *,MwalkState *,Maddr),void *user_data);
54 
55 const H null_H;
56 
57 #define maddreq(x,y) ((x).i == (y).i && (x).l == (y).l)
58 
59 
60 /***************** Misc... */
61 
62 #define DO_KIDSM(h,x) {int i,_c=_m_children(h);for(i=1;i<=_c;i++){x;}}
63 
64 #define _GET_LEVEL(h,l) (&(h).m->lP[l])
65 #define _GET_NODE(h,l,i) (&(l)->nP[i])
66 #define GET_LEVEL(h) _GET_LEVEL(h,(h).a.l)
67 #define GET_NODE(h,l) _GET_NODE(h,l,(h).a.i)
68 
69 #define spec_is_maddr_equal(got, expected) spec_total++; if (maddreq(expected,got)){putchar('.');} else {putchar('F');sprintf(failures[spec_failures++],"%s:%d expected %s to be %d.%d but was %d.%d",__FUNCTION__,__LINE__,#got,expected.l,expected.i,got.l,got.i);}
70 
71 #endif
72 
T * _t_new_from_m(H h)
Definition: mtree.c:250
Definition: ceptr_types.h:114
Definition: ceptr_types.h:42
void __m_free(H h, int free_surface)
Definition: mtree.c:284
Maddr _m_parent(H h)
Definition: mtree.c:366
H _m_unserialize(S *)
Definition: mtree.c:743
N * __m_get(H h)
Definition: mtree.c:264
H __m_new(H parent, Symbol symbol, void *surface, size_t size, uint32_t flags)
Definition: mtree.c:94
H _m_new_root(Symbol s)
Definition: mtree.c:134
Definition: ceptr_types.h:68
Definition: ceptr_types.h:56
Maddr _m_child(H h, Mindex i)
Definition: mtree.c:383
size_t _m_size(H h)
Definition: mtree.c:276
H _m_newr(H parent, Symbol s)
Definition: mtree.c:145
H _m_add(H parent, H h)
Definition: mtree.c:488
Maddr _m_next_sibling(H h)
Definition: mtree.c:459
void * _m_surface(H h)
Definition: mtree.c:352
S * _m_serialize(M *m)
Definition: mtree.c:645
H _m_newi(H h, Symbol symbol, int surface)
Definition: mtree.c:157
void _m_walk(H h, void(*walkfn)(H, N *, void *, MwalkState *, Maddr), void *user_data)
Definition: mtree.c:524
Defines types and vars for system defined semantics.
H _m_detatch(H h)
Definition: mtree.c:631
Definition: ceptr_types.h:83
Symbol _m_symbol(H h)
Definition: mtree.c:448
H _m_new_from_t(T *t)
Definition: mtree.c:206
int _m_children(H h)
Definition: mtree.c:315