Mercurial > MadButterfly
comparison tools/mb_c_source.m4 @ 154:6ce68c1f7405
Tank can fire bullet.
1. Add the redraw subject on redraw_man_t.
2. mb_c_source.m4 & mb_c_header.m4 are changed to free & remove shapes.
3. Add rdman_coord_subtree_free() to remove a subtree of coords.
4. Fix bug of rdman_remove_shape().
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 30 Sep 2008 02:44:06 +0800 |
parents | 3a4d6179e6a9 |
children | b90abd31a281 |
comparison
equal
deleted
inserted
replaced
153:9870b049b7f6 | 154:6ce68c1f7405 |
---|---|
211 free(stops); | 211 free(stops); |
212 obj->$1->free(obj->$1); | 212 obj->$1->free(obj->$1); |
213 ]]) | 213 ]]) |
214 | 214 |
215 define([F_ADD_PATH],[[ | 215 define([F_ADD_PATH],[[ |
216 rdman_remove_shape(rdman, obj->$1); | |
216 obj->$1->free(obj->$1); | 217 obj->$1->free(obj->$1); |
217 ]]) | 218 ]]) |
218 | 219 |
219 define([F_ADD_RECT],[[ | 220 define([F_ADD_RECT],[[ |
221 rdman_remove_shape(rdman, obj->$1); | |
220 obj->$1->free(obj->$1); | 222 obj->$1->free(obj->$1); |
221 ]]) | 223 ]]) |
222 | 224 |
223 define([F_ADD_TEXT],[[ | 225 define([F_ADD_TEXT],[[ |
226 rdman_remove_shape(rdman, obj->$1); | |
224 obj->$1->free(obj->$1); | 227 obj->$1->free(obj->$1); |
225 ]]) | 228 ]]) |
226 | 229 |
227 define([F_FILL_SHAPE],[[ | 230 define([F_FILL_SHAPE],[[ |
228 obj->$1_fill->free(obj->$1_fill); | 231 obj->$1_fill->free(obj->$1_fill); |
255 define([COORD_MATRIX],) | 258 define([COORD_MATRIX],) |
256 define([SHAPE_TRANSLATE],) | 259 define([SHAPE_TRANSLATE],) |
257 define([SHAPE_MATRIX],) | 260 define([SHAPE_MATRIX],) |
258 divert[]]) | 261 divert[]]) |
259 | 262 |
263 define([REVERSE_VARS],[divert([-1]) | |
264 define([__REV_VAR],[]) | |
265 define([PUSH_REV], [ | |
266 pushdef([__REV_VAR]) | |
267 define([__REV_VAR], ]QUOTE(QUOTE($[]1))[)]) | |
268 define([POP_ALL_REV], [dnl | |
269 ifelse(__REV_VAR, [], ,[UNQUOTE(__REV_VAR)[]dnl | |
270 popdef([__REV_VAR])[]POP_ALL_REV[]])]) | |
271 define([RIMPORT], [ | |
272 define(]QUOTE($[]1)[, | |
273 [PUSH_REV(]]QUOTE(QUOTE($[]1))[[(]QUOTE($[]@)[))]) | |
274 ]) | |
275 RIMPORT([ADD_LINEAR_PAINT]) | |
276 RIMPORT([ADD_RADIAL_PAINT]) | |
277 RIMPORT([COLOR_STOP]) | |
278 RIMPORT([REF_STOPS_RADIAL]) | |
279 RIMPORT([REF_STOPS_LINEAR]) | |
280 RIMPORT([ADD_PATH]) | |
281 RIMPORT([ADD_RECT]) | |
282 RIMPORT([ADD_COORD]) | |
283 RIMPORT([ADD_TEXT]) | |
284 RIMPORT([FILL_SHAPE]) | |
285 RIMPORT([STROKE_SHAPE]) | |
286 RIMPORT([FILL_SHAPE_WITH_PAINT]) | |
287 RIMPORT([STROKE_SHAPE_WITH_PAINT]) | |
288 RIMPORT([STROKE_WIDTH]) | |
289 RIMPORT([GROUP_HIDE]) | |
290 RIMPORT([RECT_HIDE]) | |
291 RIMPORT([PATH_HIDE]) | |
292 RIMPORT([COORD_TRANSLATE]) | |
293 RIMPORT([COORD_MATRIX]) | |
294 RIMPORT([SHAPE_TRANSLATE]) | |
295 RIMPORT([SHAPE_MATRIX]) | |
296 divert[]dnl | |
297 ]) | |
298 | |
260 define([MADBUTTERFLY],[dnl | 299 define([MADBUTTERFLY],[dnl |
261 [#include <stdio.h> | 300 [#include <stdio.h> |
262 #include <stdlib.h> | 301 #include <stdlib.h> |
263 #include <string.h> | 302 #include <string.h> |
264 #include "mb/mb_types.h" | 303 #include "mb/mb_types.h" |
272 grad_stop_t *stops = NULL;]DECLARE_VARS | 311 grad_stop_t *stops = NULL;]DECLARE_VARS |
273 $2[]dnl | 312 $2[]dnl |
274 [ | 313 [ |
275 obj = ($1_t *)malloc(sizeof($1_t)); | 314 obj = ($1_t *)malloc(sizeof($1_t)); |
276 if(obj == NULL) return NULL; | 315 if(obj == NULL) return NULL; |
316 obj->rdman = rdman; | |
277 ]SETUP_VARS | 317 ]SETUP_VARS |
278 obj->root_coord = rdman_coord_new(rdman, parent_coord); | 318 obj->root_coord = rdman_coord_new(rdman, parent_coord); |
279 $2 | 319 $2 |
280 [ return obj; | 320 [ return obj; |
281 } | 321 } |
282 | 322 |
283 void $1_free($1_t *obj) { | 323 void $1_free($1_t *obj) { |
284 grad_stop_t *stops = NULL; | 324 grad_stop_t *stops = NULL; |
285 ]CLEAR_VARS[]$2[ | 325 redraw_man_t *rdman; |
326 | |
327 rdman = obj->rdman; | |
328 ]REVERSE_VARS[]dnl | |
329 divert([-1])dnl | |
330 $2[]dnl | |
331 divert[]dnl | |
332 CLEAR_VARS[]dnl | |
333 POP_ALL_REV[ | |
334 rdman_coord_subtree_free(rdman, obj->root_coord); | |
286 free(obj); | 335 free(obj); |
287 } | 336 } |
288 ]dnl | 337 ]dnl |
289 ]) | 338 ]) |
290 divert[]dnl | 339 divert[]dnl |