svnno****@sourc*****
svnno****@sourc*****
2011年 3月 25日 (金) 00:45:33 JST
Revision: 462 http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=462 Author: yoya Date: 2011-03-25 00:45:33 +0900 (Fri, 25 Mar 2011) Log Message: ----------- rebuild メソッドの実装 (無効にしてある) Modified Paths: -------------- trunk/src/php_swfed.c trunk/src/php_swfed.h trunk/src/swf_object.c trunk/src/swf_object.h trunk/src/swf_tag.c trunk/src/swf_tag.h -------------- next part -------------- Modified: trunk/src/php_swfed.c =================================================================== --- trunk/src/php_swfed.c 2011-03-24 12:51:38 UTC (rev 461) +++ trunk/src/php_swfed.c 2011-03-24 15:45:33 UTC (rev 462) @@ -90,6 +90,7 @@ PHP_ME(swfed, setCompressLevel, NULL, 0) PHP_ME(swfed, swfInfo, NULL, 0) +// PHP_ME(swfed, rebuild, NULL, 0) {NULL, NULL, NULL} /* Must be the last line in swfed_functions[] */ }; /* }}} */ @@ -1204,6 +1205,12 @@ RETURN_TRUE; } +PHP_METHOD(swfed, rebuild) { + swf_object_t *swf = get_swf_object(getThis() TSRMLS_CC); + swf_object_rebuild(swf); + RETURN_TRUE; +} + PHP_METHOD(swfed, setCompressLevel) { unsigned long compress_level = 6 ; // Z_DEFAULT_COMPRESSION if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Modified: trunk/src/php_swfed.h =================================================================== --- trunk/src/php_swfed.h 2011-03-24 12:51:38 UTC (rev 461) +++ trunk/src/php_swfed.h 2011-03-24 15:45:33 UTC (rev 462) @@ -83,6 +83,7 @@ PHP_METHOD(swfed, replaceMovieClip); PHP_METHOD(swfed, swfInfo); PHP_METHOD(swfed, setCompressLevel); +PHP_METHOD(swfed, rebuild); /* Declare any global variables you may need between the BEGIN Modified: trunk/src/swf_object.c =================================================================== --- trunk/src/swf_object.c 2011-03-24 12:51:38 UTC (rev 461) +++ trunk/src/swf_object.c 2011-03-24 15:45:33 UTC (rev 462) @@ -200,6 +200,18 @@ /* --- */ void +swf_object_rebuild(swf_object_t *swf) { + int i; + swf_tag_t *tag; + for (tag = swf->tag; tag ; tag = tag->next) { + if (isShapeTag(tag->tag)) { + continue; // skip まだ動作怪しいので + } + swf_tag_rebuild(tag, swf); + } +} + +void swf_object_print(swf_object_t *swf) { int i; swf_tag_t *tag; Modified: trunk/src/swf_object.h =================================================================== --- trunk/src/swf_object.h 2011-03-24 12:51:38 UTC (rev 461) +++ trunk/src/swf_object.h 2011-03-24 15:45:33 UTC (rev 462) @@ -32,6 +32,7 @@ /* --- */ +extern void swf_object_rebuild(swf_object_t *swf); extern void swf_object_print(swf_object_t *swf); extern unsigned char *swf_object_get_tagdata(swf_object_t *swf, int tag_seqno, unsigned long *length); Modified: trunk/src/swf_tag.c =================================================================== --- trunk/src/swf_tag.c 2011-03-24 12:51:38 UTC (rev 461) +++ trunk/src/swf_tag.c 2011-03-24 15:45:33 UTC (rev 462) @@ -208,6 +208,33 @@ return 0; } +int +swf_tag_rebuild(swf_tag_t *tag, struct swf_object_ *swf) { + swf_tag_info_t *tag_info = NULL; + swf_tag_detail_handler_t * detail_handler = NULL; + int ret; + tag_info = get_swf_tag_info(tag->tag); + if (tag_info == NULL) { + return 1; // no info + } + detail_handler = tag_info->detail_handler(); + if (detail_handler == NULL) { + return 1; // no detail handler + } + if ((detail_handler->input == NULL) || (detail_handler->output == NULL)) { + return 1; // no input or output handler + } + ret = detail_handler->input(tag, swf); + if (ret) { + fprintf(stderr, "swf_tag_rebuild: detail_hander->input failed tag_no=%d\n", tag->tag); + return 1; + } + free(tag->data); + tag->data = NULL; + return 0; +} + + void swf_tag_print(swf_tag_t *tag, struct swf_object_ *swf, int indent_depth) { swf_tag_info_t *tag_info = NULL; Modified: trunk/src/swf_tag.h =================================================================== --- trunk/src/swf_tag.h 2011-03-24 12:51:38 UTC (rev 461) +++ trunk/src/swf_tag.h 2011-03-24 15:45:33 UTC (rev 462) @@ -46,6 +46,7 @@ extern swf_tag_t *swf_tag_create(bitstream_t *bs); extern void swf_tag_destroy(swf_tag_t *tag); extern int swf_tag_build(bitstream_t *bs, swf_tag_t *tag, struct swf_object_ *swf); +extern int swf_tag_rebuild(swf_tag_t *tag, struct swf_object_ *swf); extern void swf_tag_print(swf_tag_t *tag, struct swf_object_ *swf, int indent_depth); extern void *swf_tag_create_input_detail(swf_tag_t *tag, struct swf_object_ *swf); extern void swf_tag_destroy_detail(swf_tag_t *tag);