swfed extension を作成した時のメモ 準備ディレクトリ作成$ cd php-x.x.x/ext $ ./ext_skel --extname=swfed $ cd swfed configure 作成
$ vi config.m4 PHP_ARG_ENABLE から3行のコメントを外す dnl PHP_ARG_ENABLE(swfed, whether to enable swfed support, dnl Make sure that the comment is aligned: dnl [ --enable-swfed Enable swfed support]) ↑これらの dnl を消す PHP_NEW_EXTENSION に追加するファイルを指定する 前) PHP_NEW_EXTENSION(swfed, swfed.c, $ext_shared) 後) PHP_NEW_EXTENSION(swfed, swfed.c swf_object.c, $ext_shared) ↑空白 $ phpize $ ./configure $ make クラス実装定義 (php_swfed.h)
実装 (swfed.c)
PHP_METHOD(swfed, __construct) { swf_object_t *swf = swf_object_open(); int ret; ret = zend_list_insert(swf, le_swfed); object_init_ex(getThis(), swfeditor_ce); add_property_resource(getThis(), "swfed", ret); zend_list_addref(ret); }
PHP_METHOD(swfed, input) { <略> オブジェクトに紐づけたデータ処理 (というより Zend に登録したデータの一般的な引き出し方)
引数の取り方 (string 型)zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) 引数の取り方 (可変長引数1)
引数の取り方 (可変長引数2)
返り値
クラス定数の定義
#define REGISTER_SWFED_CLASS_CONST_LONG(const_name, value) \ zend_declare_class_constant_long(swfeditor_ce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); REGISTER_SWFED_CLASS_CONST_LONG("SHAPE_BITMAP_NONE", SWFED_SHAPE_BITMAP_NONE); 例外exception の飛ばし方zend_throw_exception_ex(zend_exception_get_default(), 1, "Exception at %s:%d", __FILE__, _LINE__);
参考
本家
Klab関連
|