[Swfed-svn] swfed-svn [517] removeTag メソッドを実装した

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 4月 5日 (火) 20:11:52 JST


Revision: 517
          http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=517
Author:   yoya
Date:     2011-04-05 20:11:52 +0900 (Tue, 05 Apr 2011)

Log Message:
-----------
removeTag メソッドを実装した

Modified Paths:
--------------
    trunk/src/php_swfed.c
    trunk/src/php_swfed.h
    trunk/src/swf_object.c
    trunk/src/swf_object.h


-------------- next part --------------
Modified: trunk/src/php_swfed.c
===================================================================
--- trunk/src/php_swfed.c	2011-04-03 08:20:20 UTC (rev 516)
+++ trunk/src/php_swfed.c	2011-04-05 11:11:52 UTC (rev 517)
@@ -69,6 +69,7 @@
     PHP_ME(swfed,  replaceTagDataByCID, NULL, 0)
     PHP_ME(swfed,  getTagContentsByCID, NULL, 0)
     PHP_ME(swfed,  replaceTagContentsByCID, NULL, 0)
+    PHP_ME(swfed,  removeTag, NULL, 0)
 
     PHP_ME(swfed,  getShapeData, NULL, 0)
     PHP_ME(swfed,  replaceShapeData, NULL, 0)
@@ -711,6 +712,20 @@
     RETURN_TRUE;
 }
 
+PHP_METHOD(swfed, removeTag) {
+    long tag_seqno = 0;
+    swf_object_t *swf = NULL;
+    int ret;
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &tag_seqno) == FAILURE) {
+        RETURN_FALSE;
+    }
+    swf = get_swf_object(getThis() TSRMLS_CC);
+    ret = swf_object_remove_tag(swf, tag_seqno);
+    if (ret) {
+        RETURN_FALSE;
+    }
+    RETURN_TRUE;
+}
 
 PHP_METHOD(swfed, getShapeData) {
     long cid = 0;
@@ -1355,3 +1370,4 @@
 //    printf("SWFEditor->destory\n");
     swf_object_close((swf_object_t *) resource->ptr);
 }
+

Modified: trunk/src/php_swfed.h
===================================================================
--- trunk/src/php_swfed.h	2011-04-03 08:20:20 UTC (rev 516)
+++ trunk/src/php_swfed.h	2011-04-05 11:11:52 UTC (rev 517)
@@ -61,6 +61,7 @@
 PHP_METHOD(swfed, replaceTagDataByCID);
 PHP_METHOD(swfed, getTagContentsByCID);
 PHP_METHOD(swfed, replaceTagContentsByCID);
+PHP_METHOD(swfed, removeTag);
 //
 PHP_METHOD(swfed, getShapeData);
 PHP_METHOD(swfed, replaceShapeData);

Modified: trunk/src/swf_object.c
===================================================================
--- trunk/src/swf_object.c	2011-04-03 08:20:20 UTC (rev 516)
+++ trunk/src/swf_object.c	2011-04-05 11:11:52 UTC (rev 517)
@@ -22,6 +22,8 @@
 #include "bitmap_util.h"
 #include "trans_table.h"
 
+static int _swf_object_remove_tag(swf_object_t *swf, swf_tag_t *tag);
+
 swf_object_t *
 swf_object_open(void) {
     swf_object_t *swf;
@@ -421,6 +423,42 @@
     return 1; // failure
 }
 
+int
+swf_object_remove_tag(swf_object_t *swf, int tag_seqno) {
+    swf_tag_t *tag;
+    int ret = 1;
+    tag = swf_object_search_tag_byseqno(swf, tag_seqno);
+    if (tag) {
+        ret = _swf_object_remove_tag(swf, tag);
+    }
+    return ret;
+}
+
+static int
+_swf_object_remove_tag(swf_object_t *swf, swf_tag_t *tag) {
+    if (tag->prev) {
+        if (tag->next) { // prev:O next:O
+            tag->prev->next = tag->next;
+            tag->next->prev = tag->prev;
+        } else {         // prev:O next:X
+            tag->prev->next = NULL;
+            swf->tag_tail = tag->prev;
+        }
+    } else {
+        if (tag->next) { // prev:X next:O
+            tag->next->prev = NULL;
+            swf->tag_head = tag->next;
+        } else {         // prev:X next:X
+            swf->tag_head = NULL;
+            swf->tag_tail = NULL;
+        }
+    }
+    swf_tag_destroy(tag);
+    return 0;
+}
+
+/* --- */
+
 unsigned char *
 swf_object_get_shapedata(swf_object_t *swf, int cid, unsigned long *length) {
     swf_tag_t *tag;

Modified: trunk/src/swf_object.h
===================================================================
--- trunk/src/swf_object.h	2011-04-03 08:20:20 UTC (rev 516)
+++ trunk/src/swf_object.h	2011-04-05 11:11:52 UTC (rev 517)
@@ -56,6 +56,7 @@
 extern int swf_object_replace_tagcontents_bycid(swf_object_t *swf, int cid,
                                                 unsigned char *data,
                                                 unsigned long length);
+extern int swf_object_remove_tag(swf_object_t *swf, int tag_seqno);
 
 /* --- */
 



Swfed-svn メーリングリストの案内
Back to archive index