Mercurial > MadButterfly
annotate tools/mb_c_source.m4 @ 272:01439f28d0bd
Check-in primitive integrated madbuilder code.
author | wycc |
---|---|
date | Mon, 26 Jan 2009 01:36:04 +0800 |
parents | 29acbd8a0dd0 |
children | c8b6ca46950b |
rev | line source |
---|---|
63 | 1 changequote(`[', `]')dnl |
2 include([foreach.m4])dnl | |
3 divert([-1]) | |
4 | |
64 | 5 define([UNQUOTE], [$*]) |
6 | |
7 define([QUOTE], [[[$*]]]) | |
63 | 8 |
64 | 9 define([COUNT],[ifelse([$*],[],0,[$#])]) |
63 | 10 |
64 | 11 define([IMPORT],[define([$1],[$2$1(]$[]@[)])]) |
63 | 12 |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
13 define([DECLARE_EMPTIES], [ |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
14 define([ADD_LINEAR_PAINT]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
15 define([ADD_RADIAL_PAINT]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
16 define([COLOR_STOP]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
17 define([REF_STOPS_RADIAL]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
18 define([REF_STOPS_LINEAR]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
19 define([ADD_PATH]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
20 define([ADD_RECT]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
21 define([ADD_COORD]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
22 define([ADD_TEXT],) |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
244
diff
changeset
|
23 define([ADD_IMAGE],) |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
24 define([FILL_SHAPE]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
25 define([STROKE_SHAPE]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
26 define([FILL_SHAPE_WITH_PAINT]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
27 define([STROKE_SHAPE_WITH_PAINT]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
28 define([STROKE_WIDTH]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
29 define([GROUP_HIDE],) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
30 define([RECT_HIDE],) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
31 define([PATH_HIDE],) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
32 define([COORD_TRANSLATE],) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
33 define([COORD_MATRIX],) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
34 define([SHAPE_TRANSLATE],) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
35 define([SHAPE_MATRIX],) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
36 define([ADD_SYMBOL],) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
37 define([SCENE]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
38 ]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
39 |
64 | 40 define([D_COLOR_STOP],[ |
41 {$6,$2,$3,$4,$5}]) | |
63 | 42 |
43 define([D_ADD_LINEAR_PAINT],[dnl | |
64 | 44 ifelse(COUNT($6),0,,[dnl |
45 static const int n_$1_stops = COUNT($6); | |
46 static const grad_stop_t $1_stops[[]] = {UNQUOTE($6)}; | |
63 | 47 ])dnl |
48 ]) | |
49 | |
50 define([D_ADD_RADIAL_PAINT],[dnl | |
64 | 51 ifelse(COUNT($5),0,,[dnl |
52 static const int n_$1_stops = COUNT($5); | |
53 static const grad_stop_t $1_stops[[]] = {UNQUOTE($5)}; | |
63 | 54 ])dnl |
55 ]) | |
56 | |
57 define([DECLARE_VARS], [divert([-1]) | |
64 | 58 define([DIMPORT],[IMPORT(]QUOTE($[]1)[,[D_])]) |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
59 DECLARE_EMPTIES |
64 | 60 DIMPORT([ADD_LINEAR_PAINT]) |
61 DIMPORT([ADD_RADIAL_PAINT]) | |
62 DIMPORT([COLOR_STOP]) | |
63 | 63 divert[]]) |
64 | |
65 define([S_ADD_LINEAR_PAINT],[ | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
66 obj->$1 = rdman_paint_linear_new(rdman, $2, $3, $4, $5); |
64 | 67 ifelse(COUNT($6),0,,[dnl |
68 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops); | |
69 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops); | |
70 paint_linear_stops(obj->$1, n_$1_stops, stops); | |
71 ])dnl | |
63 | 72 ]) |
64 | 73 |
63 | 74 define([S_ADD_RADIAL_PAINT],[ |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
75 obj->$1 = rdman_paint_radial_new(rdman, $2, $3, $4); |
64 | 76 ifelse(COUNT($5),0,,[ |
77 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops); | |
78 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops); | |
79 paint_radial_stops(obj->$1, n_$1_stops, stops); | |
80 ])dnl | |
63 | 81 ]) |
82 | |
64 | 83 define([S_COLOR_STOP],[]) |
78 | 84 |
85 define([S_REF_STOPS_RADIAL],[dnl | |
64 | 86 [ stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$2_stops); |
87 memcpy(stops, $2_stops, sizeof(grad_stop_t) * n_$2_stops); | |
88 paint_radial_stops(obj->$1, n_$2_stops, stops); | |
89 ]]) | |
90 | |
78 | 91 define([S_REF_STOPS_LINEAR],[dnl |
92 [ stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$2_stops); | |
93 memcpy(stops, $2_stops, sizeof(grad_stop_t) * n_$2_stops); | |
94 paint_linear_stops(obj->$1, n_$2_stops, stops); | |
95 ]]) | |
96 | |
64 | 97 define([S_ADD_RECT],[[ |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
98 obj->$1 = rdman_shape_rect_new(rdman, $2, $3, $4, $5, $6, $7); |
197
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
99 |
80
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
100 rdman_add_shape(rdman, obj->$1, obj->$8); |
64 | 101 ]]) |
102 | |
103 define([S_ADD_PATH],[[ | |
197
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
104 { |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
105 char _cmds[] = "$3"; |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
106 float _args[] = {$4}; |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
107 int _fix_args[] = {$6}; |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
108 obj->$1 = rdman_shape_path_new_from_binary(rdman, _cmds,_args,$5,_fix_args,$7); |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
109 rdman_add_shape(rdman, obj->$1, obj->$2); |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
110 } |
64 | 111 ]]) |
112 | |
113 define([S_ADD_COORD],[[ | |
66
309f1eefbec0
create new coords from redraw_man
Thinker K.F. Li <thinker@branda.to>
parents:
64
diff
changeset
|
114 obj->$1 = rdman_coord_new(rdman, obj->$2); |
64 | 115 ]]) |
116 | |
83 | 117 define([S_ADD_TEXT],[[ |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
118 obj->$1 = rdman_shape_text_new(rdman, "$2", $3, $4, $5, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
119 cairo_get_font_face(rdman->cr)); |
83 | 120 rdman_add_shape(rdman, obj->$1, obj->$6); |
121 ]]) | |
122 | |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
123 define([S_ADD_IMAGE],[[ |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
124 obj->$1_img_data = MB_IMG_LDR_LOAD(img_ldr, "$2"); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
125 obj->$1 = rdman_shape_image_new(rdman, obj->$1_img_data, |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
126 $3, $4, $5, $6); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
127 rdman_add_shape(rdman, obj->$1, obj->$7); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
128 ]]) |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
129 |
64 | 130 define([S_FILL_SHAPE_WITH_PAINT],[dnl |
131 [ rdman_paint_fill(rdman, obj->$2, obj->$1); | |
132 ]]) | |
133 | |
134 define([S_STROKE_SHAPE_WITH_PAINT],[dnl | |
135 [ rdman_paint_stroke(rdman, obj->$2, obj->$1); | |
136 ]]) | |
137 | |
138 define([S_FILL_SHAPE],[dnl | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
139 [ obj->$1_fill = rdman_paint_color_new(rdman, $2, $3, $4, $5); |
64 | 140 rdman_paint_fill(rdman, obj->$1_fill, obj->$1); |
141 ]]) | |
142 | |
143 define([S_STROKE_SHAPE],[dnl | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
144 [ obj->$1_stroke = rdman_paint_color_new(rdman, $2, $3, $4, $5); |
64 | 145 rdman_paint_stroke(rdman, obj->$1_stroke, obj->$1); |
146 ]]) | |
147 | |
80
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
148 define([S_STROKE_WIDTH],[dnl |
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
149 [ obj->$1->stroke_width = $2; |
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
150 ]]) |
e548221c04eb
svg2code.py support stroke
Thinker K.F. Li <thinker@branda.to>
parents:
78
diff
changeset
|
151 |
81 | 152 define([S_GROUP_HIDE],[dnl |
153 [ coord_hide(obj->$1); | |
154 ]]) | |
155 | |
156 define([S_RECT_HIDE],[dnl | |
157 [ sh_hide(obj->$1); | |
158 ]]) | |
159 | |
160 define([S_PATH_HIDE],[dnl | |
161 [ sh_hide(obj->$1); | |
162 ]]) | |
163 | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
164 define([S_COORD_TRANSLATE],[dnl |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
165 [ memset(obj->$1->matrix, 0, sizeof(obj->$1->matrix)); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
166 obj->$1->matrix[0] = 1; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
167 obj->$1->matrix[2] = $2; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
168 obj->$1->matrix[4] = 1; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
169 obj->$1->matrix[5] = $3; |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
170 rdman_coord_changed(rdman, obj->$1); |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
171 ]]) |
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
172 |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
173 define([S_COORD_MATRIX],[dnl |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
174 [ obj->$1->matrix[0] = $2; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
175 obj->$1->matrix[3] = $3; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
176 obj->$1->matrix[1] = $4; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
177 obj->$1->matrix[4] = $5; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
178 obj->$1->matrix[2] = $6; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
179 obj->$1->matrix[5] = $7; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
180 rdman_coord_changed(rdman, obj->$1); |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
181 ]]) |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
182 |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
183 define([S_SHAPE_TRANSLATE],[dnl |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
184 [ memset(obj->$1->matrix, 0, sizeof(obj->$1->matrix)); |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
185 obj->$1->matrix[0] = 1; |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
186 obj->$1->matrix[2] = $2; |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
187 obj->$1->matrix[4] = 1; |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
188 obj->$1->matrix[5] = $3; |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
189 rdman_coord_changed(rdman, obj->$1); |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
190 ]]) |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
191 |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
192 define([S_SHAPE_MATRIX],[dnl |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
193 [ obj->$1->matrix[0] = $2; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
194 obj->$1->matrix[3] = $3; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
195 obj->$1->matrix[1] = $4; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
196 obj->$1->matrix[4] = $5; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
197 obj->$1->matrix[2] = $6; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
198 obj->$1->matrix[5] = $7; |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
199 rdman_coord_changed(rdman, obj->$1); |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
200 ]]) |
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
201 |
63 | 202 define([SETUP_VARS],[divert([-1]) |
64 | 203 define([SIMPORT],[IMPORT(]QUOTE($[]1)[,[S_])]) |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
204 DECLARE_EMPTIES |
64 | 205 SIMPORT([ADD_LINEAR_PAINT]) |
206 SIMPORT([ADD_RADIAL_PAINT]) | |
207 SIMPORT([COLOR_STOP]) | |
78 | 208 SIMPORT([REF_STOPS_RADIAL]) |
209 SIMPORT([REF_STOPS_LINEAR]) | |
64 | 210 SIMPORT([ADD_PATH],) |
211 SIMPORT([ADD_RECT]) | |
212 SIMPORT([ADD_COORD]) | |
83 | 213 SIMPORT([ADD_TEXT]) |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
214 SIMPORT([ADD_IMAGE]) |
64 | 215 SIMPORT([FILL_SHAPE]) |
216 SIMPORT([STROKE_SHAPE]) | |
217 SIMPORT([FILL_SHAPE_WITH_PAINT]) | |
218 SIMPORT([STROKE_SHAPE_WITH_PAINT]) | |
81 | 219 SIMPORT([STROKE_WIDTH]) |
220 SIMPORT([GROUP_HIDE]) | |
221 SIMPORT([RECT_HIDE]) | |
222 SIMPORT([PATH_HIDE]) | |
84
42698de1f653
Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
223 SIMPORT([COORD_TRANSLATE]) |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
224 SIMPORT([COORD_MATRIX]) |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
85
diff
changeset
|
225 SIMPORT([SHAPE_TRANSLATE]) |
85
9b4a02bcaeb1
matrix() function in transform attribute of group and shapes
Thinker K.F. Li <thinker@branda.to>
parents:
84
diff
changeset
|
226 SIMPORT([SHAPE_MATRIX]) |
63 | 227 divert[]]) |
228 | |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
229 define([F_ADD_LINEAR_PAINT],[[ |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
230 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
|
231 free(stops); |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
232 rdman_paint_free(rdman, obj->$1); |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
233 ]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
234 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
235 define([F_ADD_RADIAL_PAINT],[[ |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
236 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
|
237 free(stops); |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
238 rdman_paint_free(rdman, obj->$1); |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
239 ]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
240 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
241 define([F_ADD_PATH],[[ |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
242 rdman_shape_free(rdman, obj->$1); |
83 | 243 ]]) |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
244 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
245 define([F_ADD_RECT],[[ |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
246 rdman_shape_free(rdman, obj->$1); |
83 | 247 ]]) |
248 | |
249 define([F_ADD_TEXT],[[ | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
250 rdman_shape_free(rdman, obj->$1); |
83 | 251 ]]) |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
252 |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
253 define([F_ADD_IMAGE],[[ |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
254 rdman_shape_free(rdman, obj->$1); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
255 MB_IMAGE_DATA_FREE(obj->$1_img_data); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
256 ]]) |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
257 |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
258 define([F_FILL_SHAPE],[[ |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
259 rdman_paint_free(rdman, obj->$1_fill); |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
260 ]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
261 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
262 define([F_STROKE_SHAPE],[[ |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
263 rdman_paint_free(rdman, obj->$1_stroke); |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
264 ]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
265 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
266 define([CLEAR_VARS],[divert([-1]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
267 define([FIMPORT],[IMPORT(]QUOTE($[]1)[,[F_])]) |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
268 DECLARE_EMPTIES |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
269 FIMPORT([ADD_LINEAR_PAINT]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
270 FIMPORT([ADD_RADIAL_PAINT]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
271 FIMPORT([ADD_PATH],) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
272 FIMPORT([ADD_RECT]) |
83 | 273 FIMPORT([ADD_TEXT]) |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
274 FIMPORT([FILL_SHAPE]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
275 FIMPORT([STROKE_SHAPE]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
276 divert[]]) |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
277 |
154 | 278 define([REVERSE_VARS],[divert([-1]) |
279 define([__REV_VAR],[]) | |
280 define([PUSH_REV], [ | |
281 pushdef([__REV_VAR]) | |
282 define([__REV_VAR], ]QUOTE(QUOTE($[]1))[)]) | |
283 define([POP_ALL_REV], [dnl | |
284 ifelse(__REV_VAR, [], ,[UNQUOTE(__REV_VAR)[]dnl | |
285 popdef([__REV_VAR])[]POP_ALL_REV[]])]) | |
286 define([RIMPORT], [ | |
287 define(]QUOTE($[]1)[, | |
288 [PUSH_REV(]]QUOTE(QUOTE($[]1))[[(]QUOTE($[]@)[))]) | |
289 ]) | |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
290 DECLARE_EMPTIES |
154 | 291 RIMPORT([ADD_LINEAR_PAINT]) |
292 RIMPORT([ADD_RADIAL_PAINT]) | |
293 RIMPORT([COLOR_STOP]) | |
294 RIMPORT([REF_STOPS_RADIAL]) | |
295 RIMPORT([REF_STOPS_LINEAR]) | |
296 RIMPORT([ADD_PATH]) | |
297 RIMPORT([ADD_RECT]) | |
298 RIMPORT([ADD_COORD]) | |
299 RIMPORT([ADD_TEXT]) | |
300 RIMPORT([FILL_SHAPE]) | |
301 RIMPORT([STROKE_SHAPE]) | |
302 RIMPORT([FILL_SHAPE_WITH_PAINT]) | |
303 RIMPORT([STROKE_SHAPE_WITH_PAINT]) | |
304 RIMPORT([STROKE_WIDTH]) | |
305 RIMPORT([GROUP_HIDE]) | |
306 RIMPORT([RECT_HIDE]) | |
307 RIMPORT([PATH_HIDE]) | |
308 RIMPORT([COORD_TRANSLATE]) | |
309 RIMPORT([COORD_MATRIX]) | |
310 RIMPORT([SHAPE_TRANSLATE]) | |
311 RIMPORT([SHAPE_MATRIX]) | |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
312 divert[]dnl |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
313 ]) |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
314 |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
315 define([Y_ADD_SYMBOL],[[{"$1", MB_SPRITE_OFFSET($1)},]]) |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
316 |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
317 define([DECLARE_SYMS], [divert([-1]) |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
318 define([YIMPORT],[IMPORT(]QUOTE($[]1)[,[Y_])]) |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
319 DECLARE_EMPTIES |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
320 YIMPORT([ADD_SYMBOL]) |
154 | 321 divert[]dnl |
322 ]) | |
323 | |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
324 define([SC_SCENE], [[static const int scene_$1[] = {] |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
325 foreach([GROUP_NAME], ($2), [[ MB_SPRITE_OFFSET(]GROUP_NAME[), |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
326 ]])dnl |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
327 [ 0 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
328 }; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
329 ]]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
330 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
331 define([DEFINE_SCENES], [divert([-1]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
332 define([SCIMPORT],[IMPORT(]QUOTE($[]1)[,[SC_])]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
333 DECLARE_EMPTIES |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
334 SCIMPORT([SCENE]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
335 divert[]dnl |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
336 ]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
337 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
338 define([SCA_SCENE], [[ scene_$1, |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
339 ]]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
340 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
341 define([DEFINE_SCENES_ARRAY], [divert([-1]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
342 define([SCAIMPORT],[IMPORT(]QUOTE($[]1)[,[SCA_])]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
343 DECLARE_EMPTIES |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
344 SCAIMPORT([SCENE]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
345 divert[]dnl |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
346 ]) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
347 |
63 | 348 define([MADBUTTERFLY],[dnl |
349 [#include <stdio.h> | |
69
a6150b4e0667
Fix bug of newing linear & radial paints
Thinker K.F. Li <thinker@branda.to>
parents:
68
diff
changeset
|
350 #include <stdlib.h> |
a6150b4e0667
Fix bug of newing linear & radial paints
Thinker K.F. Li <thinker@branda.to>
parents:
68
diff
changeset
|
351 #include <string.h> |
186
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
352 #include <mb_types.h> |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
353 #include <mb_redraw_man.h> |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
354 #include <mb_shapes.h> |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
355 #include <mb_paint.h> |
63 | 356 #include "$1.h" |
357 | |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
358 #ifdef MB_SPRITE_OFFSET |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
359 #undef MB_SPRITE_OFFSET |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
360 #endif |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
361 #define MB_SPRITE_OFFSET(x) ((int)&((($1_t *)0)->x)) |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
362 |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
363 #ifndef MB_LSYM_GET_OBJ_WITH_NAME |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
364 #define MB_LSYM_GET_OBJ_WITH_NAME |
213
a0a3196b1a05
Refactory pointer computation into a macro.
Thinker K.F. Li <thinker@branda.to>
parents:
212
diff
changeset
|
365 |
a0a3196b1a05
Refactory pointer computation into a macro.
Thinker K.F. Li <thinker@branda.to>
parents:
212
diff
changeset
|
366 #define MB_SPRITE_OFF_2_PTR(x, off) (((void *)(x)) + (off)) |
a0a3196b1a05
Refactory pointer computation into a macro.
Thinker K.F. Li <thinker@branda.to>
parents:
212
diff
changeset
|
367 |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
368 static |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
369 mb_obj_t *mb_lsym_get_obj_with_name(mb_sprite_lsym_t *lsym, const char *sym) { |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
370 int i; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
371 |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
372 for(i = 0; i < lsym->num_entries; i++) { |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
373 if(strcmp(lsym->entries[i].sym, sym) != 0) |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
374 continue; |
213
a0a3196b1a05
Refactory pointer computation into a macro.
Thinker K.F. Li <thinker@branda.to>
parents:
212
diff
changeset
|
375 return *(mb_obj_t **)MB_SPRITE_OFF_2_PTR(lsym, |
a0a3196b1a05
Refactory pointer computation into a macro.
Thinker K.F. Li <thinker@branda.to>
parents:
212
diff
changeset
|
376 lsym->entries[i].offset); |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
377 } |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
378 return NULL; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
379 } |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
380 #endif /* MB_LSYM_GET_OBJ_WITH_NAME */ |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
381 |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
382 static |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
383 mb_sprite_lsym_entry_t $1_symbols[] = {]DECLARE_SYMS |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
384 $2[ |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
385 }; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
386 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
387 ]DEFINE_SCENES |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
388 $2 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
389 DEFINE_SCENES_ARRAY |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
390 static const int *$1_scenes[[]] = { |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
391 $2[]dnl |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
392 NULL |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
393 };[ |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
394 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
395 #define SCENES_NUM ((sizeof($1_scenes) / sizeof(const int *)) - 1) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
396 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
397 static |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
398 int $1_goto_scene($1_t *sprite, int scene_no) { |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
399 coord_t *coord; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
400 const int *p; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
401 const int *scene; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
402 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
403 if(scene_no >= SCENES_NUM || scene_no < -1) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
404 return 1; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
405 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
406 if(sprite->last_scene) { |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
407 p = sprite->last_scene; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
408 while(*p != 0) { |
244
d36abace2ce4
Fix bug in *_goto_scene()
Thinker K.F. Li <thinker@branda.to>
parents:
241
diff
changeset
|
409 coord = *(coord_t **)MB_SPRITE_OFF_2_PTR(sprite, *p); |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
410 coord_hide(coord); |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
411 rdman_coord_changed(sprite->rdman, coord); |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
412 p++; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
413 } |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
414 } |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
415 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
416 if(scene_no == -1) { |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
417 sprite->last_scene = NULL; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
418 return 0; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
419 } |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
420 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
421 scene = $1_scenes[scene_no]; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
422 p = scene; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
423 while(*p != 0) { |
244
d36abace2ce4
Fix bug in *_goto_scene()
Thinker K.F. Li <thinker@branda.to>
parents:
241
diff
changeset
|
424 coord = *(coord_t **)MB_SPRITE_OFF_2_PTR(sprite, *p); |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
425 coord_show(coord); |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
426 rdman_coord_changed(sprite->rdman, coord); |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
427 p++; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
428 } |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
429 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
430 sprite->last_scene = scene; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
431 |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
432 return 0; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
433 } |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
434 |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
435 void $1_free($1_t *); |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
436 |
130
3a4d6179e6a9
change mb_c_source.m4 and mb_c_header.m4 to specify parent for SVG object
Thinker K.F. Li <thinker@branda.to>
parents:
113
diff
changeset
|
437 $1_t *$1_new(redraw_man_t *rdman, coord_t *parent_coord) { |
64 | 438 $1_t *obj; |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
439 grad_stop_t *stops = NULL; |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
440 mb_img_ldr_t *img_ldr = NULL;]DECLARE_VARS |
63 | 441 $2[]dnl |
442 [ | |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
443 img_ldr = rdman_img_ldr(rdman); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
444 |
63 | 445 obj = ($1_t *)malloc(sizeof($1_t)); |
446 if(obj == NULL) return NULL; | |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
447 |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
448 obj->lsym.sprite.free = (void (*)(mb_sprite_t *))$1_free; |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
449 obj->lsym.sprite.goto_scene = (int (*)(mb_sprite_t *, int))$1_goto_scene; |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
450 obj->lsym.sprite.get_obj_with_name = |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
451 (mb_obj_t *(*)(mb_sprite_t *, const char *))mb_lsym_get_obj_with_name; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
452 obj->lsym.num_entries = |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
453 sizeof($1_symbols) / sizeof(mb_sprite_lsym_entry_t); |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
454 obj->lsym.entries = $1_symbols; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
455 |
154 | 456 obj->rdman = rdman; |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
213
diff
changeset
|
457 obj->last_scene = NULL; |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
458 ]SETUP_VARS[ |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
459 obj->root_coord = rdman_coord_new(rdman, parent_coord);] |
63 | 460 $2 |
461 [ return obj; | |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
462 } |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
463 |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
464 void $1_free($1_t *obj) { |
68 | 465 grad_stop_t *stops = NULL; |
154 | 466 redraw_man_t *rdman; |
467 | |
468 rdman = obj->rdman; | |
469 ]REVERSE_VARS[]dnl | |
470 divert([-1])dnl | |
471 $2[]dnl | |
472 divert[]dnl | |
473 CLEAR_VARS[]dnl | |
474 POP_ALL_REV[ | |
475 rdman_coord_subtree_free(rdman, obj->root_coord); | |
67
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
476 free(obj); |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
477 } |
3f2872a1a2fe
clear objects in *_free() for generated code
Thinker K.F. Li <thinker@branda.to>
parents:
66
diff
changeset
|
478 ]dnl |
63 | 479 ]) |
480 divert[]dnl |