annotate tools/mb_c_source.m4 @ 67:3f2872a1a2fe

clear objects in *_free() for generated code
author Thinker K.F. Li <thinker@branda.to>
date Wed, 13 Aug 2008 08:05:50 +0800
parents 309f1eefbec0
children 018546012798
rev   line source
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 changequote(`[', `]')dnl
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2 include([foreach.m4])dnl
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 divert([-1])
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
5 define([UNQUOTE], [$*])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
6
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
7 define([QUOTE], [[[$*]]])
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
9 define([COUNT],[ifelse([$*],[],0,[$#])])
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
11 define([IMPORT],[define([$1],[$2$1(]$[]@[)])])
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
13 define([D_COLOR_STOP],[
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
14 {$6,$2,$3,$4,$5}])
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 define([D_ADD_LINEAR_PAINT],[dnl
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
17 ifelse(COUNT($6),0,,[dnl
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
18 static const int n_$1_stops = COUNT($6);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
19 static const grad_stop_t $1_stops[[]] = {UNQUOTE($6)};
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 ])dnl
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 ])
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 define([D_ADD_RADIAL_PAINT],[dnl
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
24 ifelse(COUNT($5),0,,[dnl
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
25 static const int n_$1_stops = COUNT($5);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
26 static const grad_stop_t $1_stops[[]] = {UNQUOTE($5)};
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27 ])dnl
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 ])
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
30 define([DECLARE_VARS], [divert([-1])
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
31 define([DIMPORT],[IMPORT(]QUOTE($[]1)[,[D_])])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
32 DIMPORT([ADD_LINEAR_PAINT])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
33 DIMPORT([ADD_RADIAL_PAINT])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
34 DIMPORT([COLOR_STOP])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
35 define([REF_STOPS],)
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
36 define([ADD_PATH],)
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
37 define([ADD_RECT])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
38 define([ADD_COORD])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
39 define([FILL_SHAPE])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
40 define([STROKE_SHAPE])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
41 define([FILL_SHAPE_WITH_PAINT])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
42 define([STROKE_SHAPE_WITH_PAINT])
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43 divert[]])
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 define([S_ADD_LINEAR_PAINT],[
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
46 obj->$1 = mb_linear_new(rdman, $2, $3, $4, $5);
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
47 ifelse(COUNT($6),0,,[dnl
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
48 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
49 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
50 paint_linear_stops(obj->$1, n_$1_stops, stops);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
51 ])dnl
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52 ])
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
53
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 define([S_ADD_RADIAL_PAINT],[
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 obj->$1 = mb_radial_new(rdman, $2, $3, $4);
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
56 ifelse(COUNT($5),0,,[
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
57 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
58 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
59 paint_radial_stops(obj->$1, n_$1_stops, stops);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
60 ])dnl
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61 ])
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
62
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
63 define([S_COLOR_STOP],[])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
64 define([S_REF_STOPS],[dnl
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
65 [ stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$2_stops);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
66 memcpy(stops, $2_stops, sizeof(grad_stop_t) * n_$2_stops);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
67 paint_radial_stops(obj->$1, n_$2_stops, stops);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
68 ]])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
69
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
70 define([S_ADD_RECT],[[
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
71 obj->$1 = sh_rect_new($2, $3, $4, $5, 0, 0);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
72 rdman_add_shape(rdman, obj->$1, obj->$6);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
73 ]])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
74
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
75 define([S_ADD_PATH],[[
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
76 obj->$1 = sh_path_new("$2");
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
77 rdman_add_shape(rdman, obj->$1, obj->$3);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
78 ]])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
79
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
80 define([S_ADD_COORD],[[
66
309f1eefbec0 create new coords from redraw_man
Thinker K.F. Li <thinker@branda.to>
parents: 64
diff changeset
81 obj->$1 = rdman_coord_new(rdman, obj->$2);
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
82 ]])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
83
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
84 define([S_FILL_SHAPE_WITH_PAINT],[dnl
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
85 [ rdman_paint_fill(rdman, obj->$2, obj->$1);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
86 ]])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
87
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
88 define([S_STROKE_SHAPE_WITH_PAINT],[dnl
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
89 [ rdman_paint_stroke(rdman, obj->$2, obj->$1);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
90 ]])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
91
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
92 define([S_FILL_SHAPE],[dnl
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
93 [ obj->$1_fill = paint_color_new(rdman, $2, $3, $4, $5);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
94 rdman_paint_fill(rdman, obj->$1_fill, obj->$1);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
95 ]])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
96
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
97 define([S_STROKE_SHAPE],[dnl
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
98 [ obj->$1_stroke = paint_color_new(rdman, $2, $3, $4, $5);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
99 rdman_paint_stroke(rdman, obj->$1_stroke, obj->$1);
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
100 ]])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
101
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
102 define([SETUP_VARS],[divert([-1])
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
103 define([SIMPORT],[IMPORT(]QUOTE($[]1)[,[S_])])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
104 SIMPORT([ADD_LINEAR_PAINT])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
105 SIMPORT([ADD_RADIAL_PAINT])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
106 SIMPORT([COLOR_STOP])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
107 SIMPORT([REF_STOPS])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
108 SIMPORT([ADD_PATH],)
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
109 SIMPORT([ADD_RECT])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
110 SIMPORT([ADD_COORD])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
111 SIMPORT([FILL_SHAPE])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
112 SIMPORT([STROKE_SHAPE])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
113 SIMPORT([FILL_SHAPE_WITH_PAINT])
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
114 SIMPORT([STROKE_SHAPE_WITH_PAINT])
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
115 divert[]])
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
116
67
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
117 define([F_ADD_LINEAR_PAINT],[[
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
118 stops = paint_linear_stops(obj->$1, 0, NULL);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
119 free(stops);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
120 obj->$1->free(obj->$1);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
121 ]])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
122
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
123 define([F_ADD_RADIAL_PAINT],[[
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
124 stops = paint_radial_stops(obj->$1, 0, NULL);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
125 free(stops);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
126 obj->$1->free(obj->$1);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
127 ]])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
128
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
129 define([F_ADD_PATH],[[
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
130 sh_path_free(obj->$1);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
131 ]]);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
132
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
133 define([F_ADD_RECT],[[
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
134 sh_rect_free(obj->$1);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
135 ]]);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
136
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
137 define([F_FILL_SHAPE],[[
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
138 obj->$1->free(obj->$1);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
139 ]])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
140
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
141 define([F_STROKE_SHAPE],[[
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
142 obj->$1->free(obj->$1);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
143 ]])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
144
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
145 define([CLEAR_VARS],[divert([-1])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
146 define([FIMPORT],[IMPORT(]QUOTE($[]1)[,[F_])])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
147 FIMPORT([ADD_LINEAR_PAINT])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
148 FIMPORT([ADD_RADIAL_PAINT])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
149 define([COLOR_STOP])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
150 define([REF_STOPS])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
151 FIMPORT([ADD_PATH],)
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
152 FIMPORT([ADD_RECT])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
153 define([ADD_COORD])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
154 FIMPORT([FILL_SHAPE])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
155 FIMPORT([STROKE_SHAPE])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
156 define([FILL_SHAPE_WITH_PAINT])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
157 define([STROKE_SHAPE_WITH_PAINT])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
158 divert[]])
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
159
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
160 define([MADBUTTERFLY],[dnl
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
161 [#include <stdio.h>
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
162 #include "mb_types.h"
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
163 #include "redraw_man.h"
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
164 #include "shapes.h"
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
165 #include "paint.h"
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
166 #include "$1.h"
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
167
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
168 $1_t *$1_new(redraw_mant_t *rdman) {
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
169 $1_t *obj;
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
170 grad_stop_t *stops = NULL;]DECLARE_VARS
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
171 $2[]dnl
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
172 [
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
173 obj = ($1_t *)malloc(sizeof($1_t));
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
174 if(obj == NULL) return NULL;
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
175 ]SETUP_VARS
64
c668c5c3ceae M4 macro for C binding.
Thinker K.F. Li <thinker@branda.to>
parents: 63
diff changeset
176 obj->root_coord = rdman->root_coord;
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
177 $2
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
178 [ return obj;
67
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
179 }
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
180
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
181 void $1_free($1_t *obj) {
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
182 grad_stop_t *stops;
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
183 ]CLEAR_VARS[]$2[
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
184 free(obj);
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
185 }
3f2872a1a2fe clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents: 66
diff changeset
186 ]dnl
63
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
187 ])
f4b792afa74e m4 translator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
188 divert[]dnl