diff -Naurp ming/ming.c ming.oden/ming.c --- ming/ming.c 2008-12-31 12:17:39.000000000 +0100 +++ ming.oden/ming.c 2011-10-26 08:33:18.000000000 +0200 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -15,10 +15,11 @@ | Authors: Dave Hayden <dave@opaque.net> | | Frank M. Kromann <fmk@php.net> | | Stuart R. Anderson <anderson@netsweng.com> | + | Klaus Rechert <klaus@rechert.de> | +----------------------------------------------------------------------+ */ -/* $Id: ming.c,v 1.79.2.4.2.10 2008/12/31 11:17:39 sebastian Exp $ */ +/* $Id$ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -38,9 +39,6 @@ #include <math.h> #include <ming.h> -#define FLOAT_Z_DVAL_PP(x) ((float)Z_DVAL_PP(x)) -#define BYTE_Z_LVAL_PP(x) ((byte)Z_LVAL_PP(x)) - #ifndef HAVE_DESTROY_SWF_BLOCK void destroySWFBlock(SWFBlock block); #endif @@ -52,8 +50,6 @@ static zend_function_entry ming_function PHP_FALIAS(ming_keypress, ming_keypress, NULL) #ifdef HAVE_NEW_MING PHP_FALIAS(ming_useconstants, ming_useConstants, NULL) -#endif -#ifdef HAVE_MING_SETSWFCOMPRESSION PHP_FALIAS(ming_setswfcompression, ming_setSWFCompression, NULL) #endif { NULL, NULL, NULL } @@ -70,16 +66,25 @@ static SWFTextField getTextField(zval *i static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC); static SWFButton getButton(zval *id TSRMLS_DC); static SWFAction getAction(zval *id TSRMLS_DC); +static SWFInitAction getInitAction(zval *id TSRMLS_DC); static SWFMorph getMorph(zval *id TSRMLS_DC); static SWFMovieClip getSprite(zval *id TSRMLS_DC); static SWFSound getSound(zval *id TSRMLS_DC); +static SWFInput getInput(zval *id TSRMLS_DC); #ifdef HAVE_NEW_MING static SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC); static SWFSoundInstance getSoundInstance(zval *id TSRMLS_DC); static SWFVideoStream getVideoStream(zval *id TSRMLS_DC); -#endif -#ifdef HAVE_SWFPREBUILTCLIP +static SWFButtonRecord getButtonRecord(zval *id TSRMLS_DC); static SWFPrebuiltClip getPrebuiltClip(zval *id TSRMLS_DC); +static SWFCharacter getCharacterClass(zval *id TSRMLS_DC); +static SWFBinaryData getBinaryData(zval *id TSRMLS_DC); +static SWFBlur getBlur(zval *id TSRMLS_DC); +static SWFShadow getShadow(zval *id TSRMLS_DC); +static SWFFilterMatrix getFilterMatrix(zval *id TSRMLS_DC); +static SWFFilter getFilter(zval *id TSRMLS_DC); +static SWFCXform getCXform(zval *id TSRMLS_DC); +static SWFMatrix getMatrix(zval *id TSRMLS_DC); #endif #define PHP_MING_FILE_CHK(file) \ @@ -91,27 +96,25 @@ static SWFPrebuiltClip getPrebuiltClip(z Set cubic threshold (?) */ PHP_FUNCTION(ming_setCubicThreshold) { - zval **num; + long num; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + return; } - convert_to_long_ex(num); - Ming_setCubicThreshold(Z_LVAL_PP(num)); + Ming_setCubicThreshold(num); } /* }}} */ -/* {{{ proto void ming_setscale(int scale) +/* {{{ proto void ming_setscale(float scale) Set scale (?) */ PHP_FUNCTION(ming_setScale) { - zval **num; + double num; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) { + return; } - convert_to_double_ex(num); - Ming_setScale(FLOAT_Z_DVAL_PP(num)); + Ming_setScale((float)num); } /* }}} */ @@ -119,13 +122,12 @@ PHP_FUNCTION(ming_setScale) Use SWF version (?) */ PHP_FUNCTION(ming_useSWFVersion) { - zval **num; + long num; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + return; } - convert_to_long_ex(num); - Ming_useSWFVersion(Z_LVAL_PP(num)); + Ming_useSWFVersion(num); } /* }}} */ @@ -134,30 +136,27 @@ PHP_FUNCTION(ming_useSWFVersion) Use constant pool (?) */ PHP_FUNCTION(ming_useConstants) { - zval **num; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_long_ex(num); + long num; - Ming_useConstants(Z_LVAL_PP(num)); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + return; + } + Ming_useConstants(num); } /* }}} */ -#endif -#ifdef HAVE_MING_SETSWFCOMPRESSION /* {{{ set output compression */ PHP_FUNCTION(ming_setSWFCompression) { - zval **num; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_long_ex(num); - Ming_setSWFCompression(Z_LVAL_PP(num)); + long num; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + return; + } + Ming_setSWFCompression(num); } /* }}} */ + #endif static int le_swfmoviep; @@ -172,6 +171,7 @@ static int le_swfdisplayitemp; static int le_swfbuttonp; static int le_swfactionp; static int le_swfmorphp; +static int le_swfmovieclipp; static int le_swfspritep; static int le_swfinputp; static int le_swfsoundp; @@ -179,10 +179,21 @@ static int le_swfsoundp; static int le_swffontcharp; static int le_swfsoundinstancep; static int le_swfvideostreamp; -#endif -#ifdef HAVE_SWFPREBUILTCLIP +static int le_swfbuttonrecordp; +static int le_swfbinarydatap; +static int le_swfinitactionp; static int le_swfprebuiltclipp; +static int le_swfsoundstreamp; +static int le_swffilterp; +static int le_swfblurp; +static int le_swfshadowp; +static int le_swffiltermatrixp; +static int le_swfcxformp; +static int le_swfmatrixp; +static int le_swfbrowserfontp; +static int le_swffontcollectionp; #endif +static int le_swfcharacterp; static zend_class_entry *movie_class_entry_ptr; static zend_class_entry *shape_class_entry_ptr; @@ -196,17 +207,31 @@ static zend_class_entry *displayitem_cla static zend_class_entry *button_class_entry_ptr; static zend_class_entry *action_class_entry_ptr; static zend_class_entry *morph_class_entry_ptr; +static zend_class_entry *movieclip_class_entry_ptr; static zend_class_entry *sprite_class_entry_ptr; static zend_class_entry *sound_class_entry_ptr; +static zend_class_entry *character_class_entry_ptr; +static zend_class_entry *input_class_entry_ptr; #ifdef HAVE_NEW_MING static zend_class_entry *fontchar_class_entry_ptr; static zend_class_entry *soundinstance_class_entry_ptr; static zend_class_entry *videostream_class_entry_ptr; -#endif -#ifdef HAVE_SWFPREBUILTCLIP +static zend_class_entry *buttonrecord_class_entry_ptr; +static zend_class_entry *binarydata_class_entry_ptr; +static zend_class_entry *initaction_class_entry_ptr; static zend_class_entry *prebuiltclip_class_entry_ptr; +static zend_class_entry *soundstream_class_entry_ptr; +static zend_class_entry *filter_class_entry_ptr; +static zend_class_entry *blur_class_entry_ptr; +static zend_class_entry *shadow_class_entry_ptr; +static zend_class_entry *filtermatrix_class_entry_ptr; +static zend_class_entry *cxform_class_entry_ptr; +static zend_class_entry *matrix_class_entry_ptr; +static zend_class_entry *browserfont_class_entry_ptr; +static zend_class_entry *fontcollection_class_entry_ptr; #endif - +static zend_class_entry *character_class_entry_ptr; + /* {{{ internal function SWFgetProperty */ static void *SWFgetProperty(zval *id, char *name, int namelen, int proptype TSRMLS_DC) @@ -218,7 +243,7 @@ static void *SWFgetProperty(zval *id, ch if (id) { if (zend_hash_find(Z_OBJPROP_P(id), name, namelen+1, (void **)&tmp) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find property %s", name); + /* php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find property %s", name); */ return NULL; } id_to_find = Z_LVAL_PP(tmp); @@ -237,7 +262,7 @@ static void *SWFgetProperty(zval *id, ch } /* }}} */ -/* {{{ SWFCharacter - not a real class +/* {{{ SWFCharacter */ /* {{{ internal function SWFCharacter getCharacter(zval *id) @@ -256,6 +281,8 @@ static SWFCharacter getCharacter(zval *i return (SWFCharacter)getButton(id TSRMLS_CC); else if (Z_OBJCE_P(id) == morph_class_entry_ptr) return (SWFCharacter)getMorph(id TSRMLS_CC); + else if (Z_OBJCE_P(id) == movieclip_class_entry_ptr) + return (SWFCharacter)getSprite(id TSRMLS_CC); else if (Z_OBJCE_P(id) == sprite_class_entry_ptr) return (SWFCharacter)getSprite(id TSRMLS_CC); else if (Z_OBJCE_P(id) == bitmap_class_entry_ptr) @@ -263,1449 +290,2815 @@ static SWFCharacter getCharacter(zval *i else if(Z_OBJCE_P(id) == sound_class_entry_ptr) return (SWFCharacter)getSound(id TSRMLS_CC); #ifdef HAVE_NEW_MING - else if(Z_OBJCE_P(id) == fontchar_class_entry_ptr) return (SWFCharacter)getFontCharacter(id TSRMLS_CC); else if(Z_OBJCE_P(id) == soundinstance_class_entry_ptr) return (SWFCharacter)getSoundInstance(id TSRMLS_CC); - else if(Z_OBJCE_P(id) == videostream_class_entry_ptr) return (SWFCharacter)getVideoStream(id TSRMLS_CC); -#endif -#ifdef HAVE_SWFPREBUILTCLIP + else if(Z_OBJCE_P(id) == buttonrecord_class_entry_ptr) + return (SWFCharacter)getButtonRecord(id TSRMLS_CC); else if(Z_OBJCE_P(id) == prebuiltclip_class_entry_ptr) return (SWFCharacter)getPrebuiltClip(id TSRMLS_CC); #endif else - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFCharacter"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCharacter"); return NULL; } /* }}} */ + +static SWFCharacter getCharacterClass(zval *id TSRMLS_DC) +{ + void *character = SWFgetProperty(id, "character", strlen("character"), le_swfcharacterp TSRMLS_CC); + + if (!character) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCharacter"); + } + return (SWFCharacter)character; +} + +/* {{{ proto swfcharacter::getWidth() */ +PHP_METHOD(swfcharacter, getWidth) +{ + RETURN_DOUBLE(SWFCharacter_getWidth(getCharacter(getThis() TSRMLS_CC))); +} +/* }}} */ + +/* {{{ proto swfcharacter::getHeight() */ +PHP_METHOD(swfcharacter, getHeight) +{ + RETURN_DOUBLE(SWFCharacter_getHeight(getCharacter(getThis() TSRMLS_CC))); +} +/* }}} */ + +static zend_function_entry swfcharacter_functions[] = { + PHP_ME(swfcharacter, getWidth, NULL, 0) + PHP_ME(swfcharacter, getHeight, NULL, 0) + { NULL, NULL, NULL } +}; + /* }}} */ -/* {{{ getInput - utility func for making an SWFInput from an fopened resource -*/ static void destroy_SWFInput_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { destroySWFInput((SWFInput)resource->ptr); } -static SWFInput getInput(zval **zfile TSRMLS_DC) +/* {{{ getInput_fromFileResource - utility func for making an SWFInput from an fopened resource */ +static SWFInput getInput_fromFileResource(zval *zfile TSRMLS_DC) { FILE *file; php_stream *stream; SWFInput input; - php_stream_from_zval_no_verify(stream, zfile); + php_stream_from_zval_no_verify(stream, &zfile); - if (stream == NULL) + if (stream == NULL) { return NULL; + } if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void *) &file, REPORT_ERRORS) != SUCCESS) { return NULL; } input = newSWFInput_file(file); - zend_list_addref(Z_LVAL_PP(zfile)); + zend_list_addref(Z_LVAL_P(zfile)); zend_list_addref(zend_list_insert(input, le_swfinputp)); return input; } /* }}} */ -/* {{{ SWFAction -*/ -/* {{{ proto void swfaction::__construct(string) - Creates a new SWFAction object, compiling the given script */ -PHP_METHOD(swfaction, __construct) +/* {{{ internal function isInput */ +static int isInput(zval *id TSRMLS_DC) { - SWFAction action; - zval **script; - int ret; + void *in = SWFgetProperty(id, "input", strlen("input"), le_swfinputp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &script) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(script); - action = compileSWFActionCode(Z_STRVAL_PP(script)); + return (in != 0); +} +/* }}} */ - if (!action) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Couldn't compile actionscript"); - } - - ret = zend_list_insert(action, le_swfactionp); +/* {{{ internal function getInput */ +static SWFInput getInput(zval *id TSRMLS_DC) +{ + void *in = SWFgetProperty(id, "input", strlen("input"), le_swfinputp TSRMLS_CC); - object_init_ex(getThis(), action_class_entry_ptr); - add_property_resource(getThis(), "action", ret); - zend_list_addref(ret); + if (!in) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFInput"); + } + return (SWFInput)in; } -/* no destructor for SWFAction, it's not a character */ /* }}} */ -/* {{{ internal function getAction - Returns the SWFAction object contained in zval *id */ -static SWFAction getAction(zval *id TSRMLS_DC) +/* {{{ proto void swfinput::__construct(string data) */ +PHP_METHOD(swfinput, __construct) { - void *action = SWFgetProperty(id, "action", 6, le_swfactionp TSRMLS_CC); + SWFInput input; + char *data; + int data_len; + int ret; - if (!action) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFAction"); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { + return; } - return (SWFAction)action; + + input = newSWFInput_bufferCopy((unsigned char *)data, data_len); + + ret = zend_list_insert(input, le_swfinputp); + object_init_ex(getThis(), input_class_entry_ptr); + add_property_resource(getThis(), "input", ret); + zend_list_addref(ret); } -/* }}} */ -static zend_function_entry swfaction_functions[] = { - PHP_ME(swfaction, __construct, NULL, 0) +static zend_function_entry swfinput_functions[] = { + PHP_ME(swfinput, __construct, NULL, 0) { NULL, NULL, NULL } }; /* }}} */ -/* {{{ SWFBitmap -*/ -/* {{{ proto void swfbitmap::__construct(mixed file [, mixed maskfile]) - Creates a new SWFBitmap object from jpg (with optional mask) or dbl file */ -PHP_METHOD(swfbitmap, __construct) +/* {{{ SWFFontCollection */ +static SWFFontCollection getFontCollection(zval *id TSRMLS_DC) { - zval **zfile, **zmask = NULL; - SWFBitmap bitmap; - SWFJpegWithAlpha bitmap_alpha; - SWFInput input, maskinput; - int ret; + void *fc = SWFgetProperty(id, "fontcollection", strlen("fontcollection"), + le_swffontcollectionp TSRMLS_CC); - if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &zfile) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 2) { - if (zend_get_parameters_ex(2, &zfile, &zmask) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else { - WRONG_PARAM_COUNT; + if (!fc) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, + "Called object is not an SWFFontCollection"); } - - if (Z_TYPE_PP(zfile) != IS_RESOURCE) { - convert_to_string_ex(zfile); - PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile)); - input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); - zend_list_addref(zend_list_insert(input, le_swfinputp)); - } else { - input = getInput(zfile TSRMLS_CC); + return (SWFFontCollection)fc; +} + +/* {{{ proto swffontcollection::init(filename) */ +PHP_METHOD(swffontcollection, __construct) +{ + char *filename; + int filename_len; + int ret; + SWFFontCollection fc; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { + return; } - - if (zmask != NULL) { - if (Z_TYPE_PP(zmask) != IS_RESOURCE) { - convert_to_string_ex(zmask); - maskinput = newSWFInput_buffer(Z_STRVAL_PP(zmask), Z_STRLEN_PP(zmask)); - zend_list_addref(zend_list_insert(maskinput, le_swfinputp)); - } else { - maskinput = getInput(zmask TSRMLS_CC); - } - bitmap_alpha = newSWFJpegWithAlpha_fromInput(input, maskinput); - if(bitmap_alpha) { - ret = zend_list_insert(bitmap_alpha, le_swfbitmapp); - object_init_ex(getThis(), bitmap_class_entry_ptr); - add_property_resource(getThis(), "bitmap", ret); - zend_list_addref(ret); - } - } else { - bitmap = newSWFBitmap_fromInput(input); - if(bitmap) { - ret = zend_list_insert(bitmap, le_swfbitmapp); - object_init_ex(getThis(), bitmap_class_entry_ptr); - add_property_resource(getThis(), "bitmap", ret); - zend_list_addref(ret); - } + + fc = newSWFFontCollection_fromFile(filename); + if(fc) { + ret = zend_list_insert(fc, le_swffontcollectionp); + object_init_ex(getThis(), fontcollection_class_entry_ptr); + add_property_resource(getThis(), "fontcollection", ret); + zend_list_addref(ret); } } +/* }}} */ -static void destroy_SWFBitmap_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +/* {{{ proto long swffontcollection::getFontCount() */ +PHP_METHOD(swffontcollection, getFontCount) { - destroySWFBitmap((SWFBitmap)resource->ptr); + RETURN_LONG(SWFFontCollection_getFontCount( + getFontCollection(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ internal function getBitmap - Returns the SWFBitmap object contained in zval *id */ -static SWFBitmap getBitmap(zval *id TSRMLS_DC) +/* {{{ proto SWFFont swffontcollection::getFont(int index) */ +PHP_METHOD(swffontcollection, getFont) { - void *bitmap = SWFgetProperty(id, "bitmap", 6, le_swfbitmapp TSRMLS_CC); + long index; + int ret; + SWFFont font; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + return; + } - if (!bitmap) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFBitmap"); + font = SWFFontCollection_getFont(getFontCollection(getThis() TSRMLS_CC), index); + + if(font != NULL) { + ret = zend_list_insert(font, le_swffontp); + object_init_ex(return_value, font_class_entry_ptr); + add_property_resource(return_value, "font", ret); + zend_list_addref(ret); } - return (SWFBitmap)bitmap; } /* }}} */ -/* {{{ proto float swfbitmap::getWidth() - Returns the width of this bitmap */ -PHP_METHOD(swfbitmap, getWidth) +static void destroy_SWFFontCollection_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } - RETURN_DOUBLE(SWFBitmap_getWidth(getBitmap(getThis() TSRMLS_CC))); + destroySWFFontCollection((SWFFontCollection)resource->ptr); } + +static zend_function_entry swffontcollection_functions[] = { + PHP_ME(swffontcollection, __construct, NULL, 0) + PHP_ME(swffontcollection, getFont, NULL, 0) + PHP_ME(swffontcollection, getFontCount, NULL, 0) + { NULL, NULL, NULL } +}; /* }}} */ -/* {{{ proto float swfbitmap::getHeight() - Returns the height of this bitmap */ -PHP_METHOD(swfbitmap, getHeight) +/* {{{ SWFBrowserFont */ +static SWFBrowserFont getBrowserFont(zval *id TSRMLS_DC) { - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; + void *bf = SWFgetProperty(id, "browserfont", strlen("browserfont"), + le_swfbrowserfontp TSRMLS_CC); + + if (!bf) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, + "Called object is not an SWFBrowserFont"); + } + return (SWFBrowserFont)bf; +} + +/* {{{ proto swfbrowserfont::_construct(fontname) */ +PHP_METHOD(swfbrowserfont, __construct) +{ + char *name; + int name_len; + int ret; + SWFBrowserFont font; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + return; + } + + font = newSWFBrowserFont(name); + if(font) { + ret = zend_list_insert(font, le_swfbrowserfontp); + object_init_ex(getThis(), browserfont_class_entry_ptr); + add_property_resource(getThis(), "browserfont", ret); + zend_list_addref(ret); } - RETURN_DOUBLE(SWFBitmap_getHeight(getBitmap(getThis() TSRMLS_CC))); } /* }}} */ -static zend_function_entry swfbitmap_functions[] = { - PHP_ME(swfbitmap, __construct, NULL, 0) - PHP_ME(swfbitmap, getWidth, NULL, 0) - PHP_ME(swfbitmap, getHeight, NULL, 0) +static void destroy_SWFBrowserFont_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFBrowserFont((SWFBrowserFont)resource->ptr); +} + +static zend_function_entry swfbrowserfont_functions[] = { + PHP_ME(swfbrowserfont, __construct, NULL, 0) { NULL, NULL, NULL } }; - /* }}} */ -/* {{{ SWFButton +/* {{{ SWFCXform */ -/* {{{ proto void swfbutton::__construct() - Creates a new SWFButton object */ -PHP_METHOD(swfbutton, __construct) +/* {{{ proto void swfcxform::__construct([rAdd, gAdd, bAdd, aAdd, rMult, gMult, bMult, aMult]) */ +PHP_METHOD(swfcxform, __construct) { - SWFButton button = newSWFButton(); - int ret = zend_list_insert(button, le_swfbuttonp); + SWFCXform cx; + long rAdd, gAdd, bAdd, aAdd; + double rMult, gMult, bMult, aMult; + int ret; - object_init_ex(getThis(), button_class_entry_ptr); - add_property_resource(getThis(), "button", ret); + switch(ZEND_NUM_ARGS()) + { + case 0: + cx = newSWFCXform(0, 0, 0, 0, 1.0, 1.0, 1.0, 1.0); + break; + case 8: + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllldddd", + &rAdd, &gAdd, &bAdd, &aAdd, + &rMult, &gMult, &bMult, &aMult) == FAILURE) { + return; + } + cx = newSWFCXform(rAdd, gAdd, bAdd, aAdd, rMult, gMult, bMult, aMult); + break; + default: + WRONG_PARAM_COUNT; + } + + ret = zend_list_insert(cx, le_swfcxformp); + object_init_ex(getThis(), cxform_class_entry_ptr); + add_property_resource(getThis(), "cx", ret); zend_list_addref(ret); } +/* }}} */ -static void destroy_SWFButton_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +/* {{{ proto void setColorAdd(r, g, b, a) */ +PHP_METHOD(swfcxform, setColorAdd) { - destroySWFButton((SWFButton)resource->ptr); + long rAdd, gAdd, bAdd, aAdd; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &rAdd, &gAdd, &bAdd, &aAdd) == FAILURE) { + return; + } + + SWFCXform_setColorAdd(getCXform(getThis() TSRMLS_CC), rAdd, gAdd, bAdd, aAdd); } /* }}} */ -/* {{{ internal function getButton - Returns the SWFButton object contained in zval *id */ -static SWFButton getButton(zval *id TSRMLS_DC) +/* {{{ proto void setColorMult(r, g, b, a) */ +PHP_METHOD(swfcxform, setColorMult) { - void *button = SWFgetProperty(id, "button", 6, le_swfbuttonp TSRMLS_CC); + double rMult, gMult, bMult, aMult; - if (!button) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFButton"); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &rMult, &gMult, &bMult, &aMult) == FAILURE) { + return; } - return (SWFButton)button; + + SWFCXform_setColorMult(getCXform(getThis() TSRMLS_CC), rMult, gMult, bMult, aMult); } /* }}} */ -/* {{{ proto void swfbutton::setHit(object SWFCharacter) - Sets the character for this button's hit test state */ -PHP_METHOD(swfbutton, setHit) +static void destroy_SWFCXform_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - zval **zchar; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; + destroySWFCXform((SWFCXform)resource->ptr); +} - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; - } +/* {{{ internal function getCXform */ +static SWFCXform getCXform(zval *id TSRMLS_DC) +{ + void *cx = SWFgetProperty(id, "cx", strlen("cx"), le_swfcxformp TSRMLS_CC); - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - SWFButton_addShape(button, character, SWFBUTTONRECORD_HITSTATE); + if (!cx) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCXform"); + } + return (SWFCXform)cx; } /* }}} */ -/* {{{ proto void swfbutton::setOver(object SWFCharacter) - Sets the character for this button's over state */ -PHP_METHOD(swfbutton, setOver) +static zend_function_entry swfcxform_functions[] = { + PHP_ME(swfcxform, __construct, NULL, 0) + PHP_ME(swfcxform, setColorAdd, NULL, 0) + PHP_ME(swfcxform, setColorMult, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ + +/* {{{ SWFMatrix */ + +static SWFMatrix getMatrix(zval *id TSRMLS_DC) { - zval **zchar; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; + void *matrix = SWFgetProperty(id, "matrix", strlen("matrix"), le_swfmatrixp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; + if(!matrix) + { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMatrix"); } - - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - SWFButton_addShape(button, character, SWFBUTTONRECORD_OVERSTATE); + return (SWFMatrix)matrix; } -/* }}} */ -/* {{{ proto void swfbutton::setUp(object SWFCharacter) - Sets the character for this button's up state */ -PHP_METHOD(swfbutton, setUp) +/* {{{ proto double swfmatrix::getScaleX */ +PHP_METHOD(swfmatrix, getScaleX) { - zval **zchar; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - SWFButton_addShape(button, character, SWFBUTTONRECORD_UPSTATE); + RETURN_DOUBLE(SWFMatrix_getScaleX(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto void swfbutton::setDown(object SWFCharacter) - Sets the character for this button's down state */ -PHP_METHOD(swfbutton, setDown) +/* {{{ proto double swfmatrix::getScaleX */ +PHP_METHOD(swfmatrix, getScaleY) { - zval **zchar; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - SWFButton_addShape(button, character, SWFBUTTONRECORD_DOWNSTATE); + RETURN_DOUBLE(SWFMatrix_getScaleY(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto void swfbutton::addShape(object SWFCharacter, int flags) - Sets the character to display for the condition described in flags */ -PHP_METHOD(swfbutton, addShape) +/* {{{ proto double swfmatrix::getRotate0 */ +PHP_METHOD(swfmatrix, getRotate0) { - zval **zchar, **flags; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; - - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zchar, &flags) == FAILURE) { + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - convert_to_long_ex(flags); - SWFButton_addShape(button, character, BYTE_Z_LVAL_PP(flags)); + RETURN_DOUBLE(SWFMatrix_getRotate0(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -#ifdef HAVE_NEW_MING -/* {{{ proto void swfbutton::setMenu(int flag) - enable track as menu button behaviour */ - -PHP_METHOD(swfbutton, setMenu) +/* {{{ proto double swfmatrix::getRotate0 */ +PHP_METHOD(swfmatrix, getRotate1) { - zval **zflag; - SWFButton button = getButton(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zflag) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_long_ex(zflag); - - SWFButton_setMenu(button, Z_LVAL_PP(zflag)); + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + RETURN_DOUBLE(SWFMatrix_getRotate1(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -#endif -/* {{{ proto void swfbutton::setAction(object SWFAction) - Sets the action to perform when button is pressed */ -PHP_METHOD(swfbutton, setAction) +/* {{{ proto double swfmatrix::getTranslateX */ +PHP_METHOD(swfmatrix, getTranslateX) { - zval **zaction; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFAction action; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zaction) == FAILURE) { + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - - convert_to_object_ex(zaction); - action = getAction(*zaction TSRMLS_CC); - SWFButton_addAction(button, action, SWFBUTTON_OVERDOWNTOOVERUP); + RETURN_DOUBLE(SWFMatrix_getTranslateX(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -#ifdef HAVE_NEW_MING -/* {{{ proto SWFSoundInstance swfbutton::addASound(SWFSound sound, int flags) - associates a sound with a button transition - NOTE: the transitions are all wrong _UP, _OVER, _DOWN _HIT */ - -PHP_METHOD(swfbutton, addSound) +/* {{{ proto double swfmatrix::getTranslateY */ +PHP_METHOD(swfmatrix, getTranslateY) { - zval **zsound, **flags; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFSound sound; - SWFSoundInstance item; - int ret; - - if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zsound, &flags) == FAILURE) + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; - - convert_to_object_ex(zsound); - sound = getSound(*zsound TSRMLS_CC); - - convert_to_long_ex(flags); - - item = SWFButton_addSound(button, sound, Z_LVAL_PP(flags)); - - if(item != NULL) { - /* try and create a soundinstance object */ - ret = zend_list_insert(item, le_swfsoundinstancep); - object_init_ex(return_value, soundinstance_class_entry_ptr); - add_property_resource(return_value, "soundinstance", ret); - zend_list_addref(ret); } + RETURN_DOUBLE(SWFMatrix_getTranslateY(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -#endif -/* {{{ proto void swfbutton::addAction(object SWFAction, int flags) - Sets the action to perform when conditions described in flags is met */ -PHP_METHOD(swfbutton, addAction) +static zend_function_entry swfmatrix_functions[] = { + PHP_ME(swfmatrix, getScaleX, NULL, 0) + PHP_ME(swfmatrix, getScaleY, NULL, 0) + PHP_ME(swfmatrix, getRotate0, NULL, 0) + PHP_ME(swfmatrix, getRotate1, NULL, 0) + PHP_ME(swfmatrix, getTranslateX, NULL, 0) + PHP_ME(swfmatrix, getTranslateY, NULL, 0) + {NULL, NULL, NULL} +}; +/* }}} */ + +/* {{{ SWFInitAction +*/ +/* {{{ proto void swfinitaction::__construct(action,[id]) + Creates a new SWFInitAction object. */ +PHP_METHOD(swfinitaction, __construct) { - zval **zaction, **flags; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFAction action; + SWFInitAction init; + zval *zaction; + int ret; + long id = -1; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zaction, &flags) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &zaction, &id) == FAILURE) { + return; } - convert_to_object_ex(zaction); - action = getAction(*zaction TSRMLS_CC); - convert_to_long_ex(flags); - SWFButton_addAction(button, action, Z_LVAL_PP(flags)); + if (id==-1) { + init = newSWFInitAction(getAction(zaction TSRMLS_CC)); + } else { + init = newSWFInitAction_withId(getAction(zaction TSRMLS_CC), id); + } + + ret = zend_list_insert(init, le_swfinitactionp); + object_init_ex(getThis(), initaction_class_entry_ptr); + add_property_resource(getThis(), "initaction", ret); + zend_list_addref(ret); } +/* no destructor for SWFInitAction, it's not a character */ /* }}} */ -/* {{{ proto int ming_keypress(string str) - Returns the action flag for keyPress(char) */ -PHP_FUNCTION(ming_keypress) +/* {{{ internal function getInitAction + Returns the SWFInitAction object contained in zval *id */ +static inline SWFInitAction getInitAction(zval *id TSRMLS_DC) { - zval **key; - char c; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &key) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(key); + void *action = SWFgetProperty(id, "initaction", + strlen("initaction"), le_swfinitactionp TSRMLS_CC); - if (Z_STRLEN_PP(key) > 1) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Only one character expected"); + if (!action) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFInitAction"); } - - c = Z_STRVAL_PP(key)[0]; - RETURN_LONG((c&0x7f)<<9); + return (SWFInitAction)action; } /* }}} */ -static zend_function_entry swfbutton_functions[] = { - PHP_ME(swfbutton, __construct, NULL, 0) - PHP_ME(swfbutton, setHit, NULL, 0) - PHP_ME(swfbutton, setOver, NULL, 0) - PHP_ME(swfbutton, setUp, NULL, 0) - PHP_ME(swfbutton, setDown, NULL, 0) - PHP_ME(swfbutton, setAction, NULL, 0) - PHP_ME(swfbutton, addShape, NULL, 0) -#ifdef HAVE_NEW_MING - PHP_ME(swfbutton, setMenu, NULL, 0) -#endif - PHP_ME(swfbutton, addAction, NULL, 0) -#ifdef HAVE_NEW_MING - PHP_ME(swfbutton, addSound, NULL, 0) -#endif +static zend_function_entry swfinitaction_functions[] = { + PHP_ME(swfinitaction, __construct, NULL, 0) { NULL, NULL, NULL } }; - /* }}} */ -/* {{{ SWFDisplayitem +/* {{{ SWFAction */ -/* {{{ internal function getDisplayItem - Returns the SWFDisplayItem contained in zval *id */ -static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC) +/* {{{ proto void swfaction::__construct(string) + Creates a new SWFAction object, compiling the given script */ +PHP_METHOD(swfaction, __construct) { - void *item = SWFgetProperty(id, "displayitem", 11, le_swfdisplayitemp TSRMLS_CC); + SWFAction action; + char *script; + int script_len; + int ret; - if (!item) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFDisplayItem"); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &script, &script_len) == FAILURE) { + return; } + + action = newSWFAction(script); - return (SWFDisplayItem)item; + if (!action) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Couldn't compile actionscript"); + } + + ret = zend_list_insert(action, le_swfactionp); + + object_init_ex(getThis(), action_class_entry_ptr); + add_property_resource(getThis(), "action", ret); + zend_list_addref(ret); } +/* no destructor for SWFAction, it's not a character */ /* }}} */ -/* {{{ proto void swfdisplayitem::moveTo(int x, int y) - Moves this SWFDisplayItem to movie coordinates (x, y) */ -PHP_METHOD(swfdisplayitem, moveTo) +/* {{{ proto long swfaction::compile(version) */ +PHP_METHOD(swfaction, compile) { - zval **x, **y; + long version; + int len, ret; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &version) == FAILURE) { + return; } + + ret = SWFAction_compile(getAction(getThis() TSRMLS_CC), version, &len); - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFDisplayItem_moveTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + if (ret != 0) { + RETURN_LONG(-1); + } + else { + RETURN_LONG(len); + } } /* }}} */ -/* {{{ proto void swfdisplayitem::move(float dx, float dy) - Displaces this SWFDisplayItem by (dx, dy) in movie coordinates */ -PHP_METHOD(swfdisplayitem, move) +/* {{{ internal function getAction + Returns the SWFAction object contained in zval *id */ +static SWFAction getAction(zval *id TSRMLS_DC) { - zval **x, **y; + void *action = SWFgetProperty(id, "action", 6, le_swfactionp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (!action) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFAction"); } - - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFDisplayItem_move(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + return (SWFAction)action; } /* }}} */ -/* {{{ proto void swfdisplayitem::scaleTo(float xScale [, float yScale]) - Scales this SWFDisplayItem by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ -PHP_METHOD(swfdisplayitem, scaleTo) +static zend_function_entry swfaction_functions[] = { + PHP_ME(swfaction, __construct, NULL, 0) + PHP_ME(swfaction, compile, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ + +/* {{{ SWFBitmap +*/ +/* {{{ proto void swfbitmap::__construct(filename or SWFInput [, maskfilename / SWFInput]) + Creates a new SWFBitmap object from jpg (with optional mask) or dbl file */ +PHP_METHOD(swfbitmap, __construct) { - zval **x, **y; + zval *zfile, *zmask = NULL; + SWFBitmap bitmap; + SWFJpegWithAlpha bitmap_alpha; + SWFInput input = NULL, maskinput = NULL; + int ret; - if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &zfile, &zmask) == FAILURE) { + return; + } + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening bitmap file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "swfbitmap::__construct: need either a filename, " + "a file ressource or SWFInput buffer."); + } + + if (zmask != NULL) { + switch(Z_TYPE_P(zmask)) + { + case IS_RESOURCE: + maskinput = getInput_fromFileResource(zmask TSRMLS_CC); + break; + case IS_OBJECT: + maskinput = getInput(zmask TSRMLS_CC); + break; + case IS_STRING: + maskinput = newSWFInput_filename(Z_STRVAL_P(zmask)); + if(maskinput == NULL) + php_error(E_ERROR, "opening mask file failed"); + zend_list_addref(zend_list_insert(maskinput, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "swfbitmap::__construct: need either a filename, " + "a file ressource or SWFInput buffer."); } - convert_to_double_ex(x); - SWFDisplayItem_scaleTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(x)); - } else if (ZEND_NUM_ARGS() == 2) { - if (zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + + /* XXX: this is very optimistic! is it really a JPEG ?!? */ + bitmap_alpha = newSWFJpegWithAlpha_fromInput(input, maskinput); + if(bitmap_alpha) { + ret = zend_list_insert(bitmap_alpha, le_swfbitmapp); + object_init_ex(getThis(), bitmap_class_entry_ptr); + add_property_resource(getThis(), "bitmap", ret); + zend_list_addref(ret); } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFDisplayItem_scaleTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); } else { - WRONG_PARAM_COUNT; + bitmap = newSWFBitmap_fromInput(input); + if(bitmap) { + ret = zend_list_insert(bitmap, le_swfbitmapp); + object_init_ex(getThis(), bitmap_class_entry_ptr); + add_property_resource(getThis(), "bitmap", ret); + zend_list_addref(ret); + } } } + +static void destroy_SWFBitmap_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFBitmap((SWFBitmap)resource->ptr); +} /* }}} */ -/* {{{ proto void swfdisplayitem::scale(float xScale, float yScale) - Multiplies this SWFDisplayItem's current x scale by xScale, its y scale by yScale */ -PHP_METHOD(swfdisplayitem, scale) +/* {{{ internal function getBitmap + Returns the SWFBitmap object contained in zval *id */ +static SWFBitmap getBitmap(zval *id TSRMLS_DC) { - zval **x, **y; + void *bitmap = SWFgetProperty(id, "bitmap", 6, le_swfbitmapp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (!bitmap) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFBitmap"); } - - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFDisplayItem_scale(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + return (SWFBitmap)bitmap; } /* }}} */ -/* {{{ proto void swfdisplayitem::rotateTo(float degrees) - Rotates this SWFDisplayItem the given (clockwise) degrees from its original orientation */ -PHP_METHOD(swfdisplayitem, rotateTo) +/* {{{ proto float swfbitmap::getWidth() + Returns the width of this bitmap */ +PHP_METHOD(swfbitmap, getWidth) { - zval **degrees; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, °rees) == FAILURE) { - WRONG_PARAM_COUNT; + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; } - - convert_to_double_ex(degrees); - SWFDisplayItem_rotateTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(degrees)); + RETURN_DOUBLE(SWFBitmap_getWidth(getBitmap(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto void swfdisplayitem::rotate(float degrees) - Rotates this SWFDisplayItem the given (clockwise) degrees from its current orientation */ -PHP_METHOD(swfdisplayitem, rotate) +/* {{{ proto float swfbitmap::getHeight() + Returns the height of this bitmap */ +PHP_METHOD(swfbitmap, getHeight) { - zval **degrees; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, °rees) == FAILURE) { - WRONG_PARAM_COUNT; + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; } - - convert_to_double_ex(degrees); - SWFDisplayItem_rotate(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(degrees)); + RETURN_DOUBLE(SWFBitmap_getHeight(getBitmap(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto void swfdisplayitem::skewXTo(float xSkew) - Sets this SWFDisplayItem's x skew value to xSkew */ -PHP_METHOD(swfdisplayitem, skewXTo) +static zend_function_entry swfbitmap_functions[] = { + PHP_ME(swfbitmap, __construct, NULL, 0) + PHP_ME(swfbitmap, getWidth, NULL, 0) + PHP_ME(swfbitmap, getHeight, NULL, 0) + { NULL, NULL, NULL } +}; + +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ internal function */ +static +SWFButtonRecord getButtonRecord(zval *id TSRMLS_DC) { - zval **x; + void *record = SWFgetProperty(id, "buttonrecord", strlen("buttonrecord"), le_swfbuttonrecordp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_double_ex(x); - SWFDisplayItem_skewXTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x)); + if(!record) + php_error(E_ERROR, "called object is not an SWFButtonRecord!"); + + return (SWFButtonRecord)record; } /* }}} */ -/* {{{ proto void swfdisplayitem::skewX(float xSkew) - Adds xSkew to this SWFDisplayItem's x skew value */ -PHP_METHOD(swfdisplayitem, skewX) +/* {{{ proto void swfbuttoncharacter::setDepth(int depth) + sets a button characters depth */ +PHP_METHOD(swfbuttonrecord, setDepth) { - zval **x; + long depth; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &depth) == FAILURE) { + return; } - - convert_to_double_ex(x); - SWFDisplayItem_skewX(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x)); + SWFButtonRecord_setDepth(getButtonRecord(getThis() TSRMLS_CC), depth); } /* }}} */ -/* {{{ proto void swfdisplayitem::skewYTo(float ySkew) - Sets this SWFDisplayItem's y skew value to ySkew */ -PHP_METHOD(swfdisplayitem, skewYTo) +/* {{{ proto void swfbuttoncharacter::setBlendMode(int mode) + assigns a blend mode to a button's character */ +PHP_METHOD(swfbuttonrecord, setBlendMode) { - zval **y; + long mode; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { + return; } - - convert_to_double_ex(y); - SWFDisplayItem_skewYTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(y)); + SWFButtonRecord_setBlendMode(getButtonRecord(getThis() TSRMLS_CC), mode); } /* }}} */ -/* {{{ proto void swfdisplayitem::skewY(float ySkew) - Adds ySkew to this SWFDisplayItem's y skew value */ -PHP_METHOD(swfdisplayitem, skewY) +/* {{{ proto void swfbuttoncharacter::move(double x, double y) + relative placement */ +PHP_METHOD(swfbuttonrecord, move) { - zval **y; + double x, y; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - - convert_to_double_ex(y); - SWFDisplayItem_skewY(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(y)); + SWFButtonRecord_move(getButtonRecord(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfdisplayitem::setMatrix(float a, float b, float c, float d, float x, float y) - Sets the item's transform matrix */ -PHP_METHOD(swfdisplayitem, setMatrix) +/* {{{ proto void swfbuttoncharacter::moveTo(double x, double y) + absolute placement */ +PHP_METHOD(swfbuttonrecord, moveTo) { - zval **a, **b, **c, **d, **x, **y; + double x, y; - if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &a, &b, &c, &d, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - - convert_to_double_ex(a); - convert_to_double_ex(b); - convert_to_double_ex(c); - convert_to_double_ex(d); - convert_to_double_ex(x); - convert_to_double_ex(y); - - SWFDisplayItem_setMatrix( getDisplayItem(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(a), FLOAT_Z_DVAL_PP(b), FLOAT_Z_DVAL_PP(c), FLOAT_Z_DVAL_PP(d), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y) - ); + SWFButtonRecord_moveTo(getButtonRecord(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfdisplayitem::setDepth(int depth) - Sets this SWFDisplayItem's z-depth to depth. Items with higher depth values are drawn on top of those with lower values */ -PHP_METHOD(swfdisplayitem, setDepth) +/* {{{ proto void swfbuttoncharacter::rotate(double deg) + relative rotation */ +PHP_METHOD(swfbuttonrecord, rotate) { - zval **depth; + double deg; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &depth) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °) == FAILURE) { + return; } - - convert_to_long_ex(depth); - SWFDisplayItem_setDepth(getDisplayItem(getThis() TSRMLS_CC), Z_LVAL_PP(depth)); + SWFButtonRecord_rotate(getButtonRecord(getThis() TSRMLS_CC), deg); } /* }}} */ -/* {{{ proto void swfdisplayitem::setRatio(float ratio) - Sets this SWFDisplayItem's ratio to ratio. Obviously only does anything if displayitem was created from an SWFMorph */ -PHP_METHOD(swfdisplayitem, setRatio) +/* {{{ proto void swfbuttoncharacter::rotateTo(double deg) + absolute rotation */ +PHP_METHOD(swfbuttonrecord, rotateTo) { - zval **ratio; + double deg; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ratio) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °) == FAILURE) { + return; + } + SWFButtonRecord_rotateTo(getButtonRecord(getThis() TSRMLS_CC), deg); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::scale(double x, double y) + relative scaling */ +PHP_METHOD(swfbuttonrecord, scale) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + SWFButtonRecord_scale(getButtonRecord(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::scaleTo(double x, double y) + absolute scaling */ +PHP_METHOD(swfbuttonrecord, scaleTo) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + SWFButtonRecord_scaleTo(getButtonRecord(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::skewX(double x) */ +PHP_METHOD(swfbuttonrecord, skewX) +{ + double x; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } + SWFButtonRecord_skewX(getButtonRecord(getThis() TSRMLS_CC), x); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::skewXTo(double x) */ +PHP_METHOD(swfbuttonrecord, skewXTo) +{ + double x; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } + SWFButtonRecord_skewXTo(getButtonRecord(getThis() TSRMLS_CC), x); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::skewY(double y) */ +PHP_METHOD(swfbuttonrecord, skewY) +{ + double y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } + SWFButtonRecord_skewY(getButtonRecord(getThis() TSRMLS_CC), y); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::skewYTo(double y) */ +PHP_METHOD(swfbuttonrecord, skewYTo) +{ + double y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } + SWFButtonRecord_skewYTo(getButtonRecord(getThis() TSRMLS_CC), y); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::addFilter(SWFFilter f) */ +PHP_METHOD(swfbuttonrecord, addFilter) +{ + zval *filter; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &filter) == FAILURE) { + return; + } + SWFButtonRecord_addFilter(getButtonRecord(getThis() TSRMLS_CC), getFilter(filter TSRMLS_CC)); +} +/* }}} */ + +static zend_function_entry swfbuttonrecord_functions[] = { + PHP_ME(swfbuttonrecord, setDepth, NULL, 0) + PHP_ME(swfbuttonrecord, setBlendMode, NULL, 0) + PHP_ME(swfbuttonrecord, move, NULL, 0) + PHP_ME(swfbuttonrecord, moveTo, NULL, 0) + PHP_ME(swfbuttonrecord, rotate, NULL, 0) + PHP_ME(swfbuttonrecord, rotateTo, NULL, 0) + PHP_ME(swfbuttonrecord, scale, NULL, 0) + PHP_ME(swfbuttonrecord, scaleTo, NULL, 0) + PHP_ME(swfbuttonrecord, skewX, NULL, 0) + PHP_ME(swfbuttonrecord, skewXTo, NULL, 0) + PHP_ME(swfbuttonrecord, skewY, NULL, 0) + PHP_ME(swfbuttonrecord, skewYTo, NULL, 0) + PHP_ME(swfbuttonrecord, addFilter, NULL, 0) + { NULL, NULL, NULL } +}; +#endif + +/* {{{ SWFButton +*/ +/* {{{ proto void swfbutton::__construct() + Creates a new SWFButton object */ +PHP_METHOD(swfbutton, __construct) +{ + SWFButton button = newSWFButton(); + int ret = zend_list_insert(button, le_swfbuttonp); + + object_init_ex(getThis(), button_class_entry_ptr); + add_property_resource(getThis(), "button", ret); + zend_list_addref(ret); +} + +static void destroy_SWFButton_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFButton((SWFButton)resource->ptr); +} +/* }}} */ + +/* {{{ internal function getButton + Returns the SWFButton object contained in zval *id */ +static SWFButton getButton(zval *id TSRMLS_DC) +{ + void *button = SWFgetProperty(id, "button", 6, le_swfbuttonp TSRMLS_CC); + + if (!button) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFButton"); + } + return (SWFButton)button; +} +/* }}} */ + +/* {{{ proto void swfbutton::setHit(object SWFCharacter) + Sets the character for this button's hit test state */ +PHP_METHOD(swfbutton, setHit) +{ + zval *zchar; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, SWFBUTTONRECORD_HITSTATE); +} +/* }}} */ + +/* {{{ proto void swfbutton::setOver(object SWFCharacter) + Sets the character for this button's over state */ +PHP_METHOD(swfbutton, setOver) +{ + zval *zchar; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, SWFBUTTONRECORD_OVERSTATE); +} +/* }}} */ + +/* {{{ proto void swfbutton::setUp(object SWFCharacter) + Sets the character for this button's up state */ +PHP_METHOD(swfbutton, setUp) +{ + zval *zchar; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, SWFBUTTONRECORD_UPSTATE); +} +/* }}} */ + +/* {{{ proto void swfbutton::setDown(object SWFCharacter) + Sets the character for this button's down state */ +PHP_METHOD(swfbutton, setDown) +{ + zval *zchar; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, SWFBUTTONRECORD_DOWNSTATE); +} +/* }}} */ + +/* {{{ proto void swfbutton::addShape(object SWFCharacter, int flags) + Sets the character to display for the condition described in flags */ +PHP_METHOD(swfbutton, addShape) +{ + zval *zchar; + long flags; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zchar, &flags) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, flags); +} +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ proto swfbuttonrecord swfbutton::addCharacter(object SWFCharacter, int flags) + Sets the character to display for the condition described in flags */ +PHP_METHOD(swfbutton, addCharacter) +{ + zval *zchar; + long flags; + SWFButtonRecord record; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zchar, &flags) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + record = SWFButton_addCharacter(button, character, flags); + + if(record != NULL) + { + ret = zend_list_insert(record, le_swfbuttonrecordp); + object_init_ex(return_value, buttonrecord_class_entry_ptr); + add_property_resource(return_value, "buttonrecord", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +/* {{{ proto void swfbutton::setMenu(int flag) + enable track as menu button behaviour */ +PHP_METHOD(swfbutton, setMenu) +{ + long flag; + SWFButton button = getButton(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) { + return; + } + SWFButton_setMenu(button, flag); +} +/* }}} */ + +/* {{{ proto void swfbutton::setScalingGrid(int x, int y, int w, int h) */ +PHP_METHOD(swfbutton, setScalingGrid) +{ + long x, y, w, h; + SWFButton button = getButton(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &x, &y, &w, &h) == FAILURE) { + return; + } + SWFButton_setScalingGrid(button, x, y, w, h); +} +/* }}} */ + +/* {{{ proto void swfbutton::removeScalingGrid() */ +PHP_METHOD(swfbutton, removeScalingGrid) +{ + SWFButton button = getButton(getThis() TSRMLS_CC); + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + SWFButton_removeScalingGrid(button); +} +/* }}} */ +#endif + +/* {{{ proto void swfbutton::setAction(object SWFAction) + Sets the action to perform when button is pressed */ +PHP_METHOD(swfbutton, setAction) +{ + zval *zaction; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFAction action; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zaction) == FAILURE) { + return; + } + + action = getAction(zaction TSRMLS_CC); + SWFButton_addAction(button, action, SWFBUTTON_OVERDOWNTOOVERUP); +} +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ proto SWFSoundInstance swfbutton::addASound(SWFSound sound, int flags) + associates a sound with a button transition + NOTE: the transitions are all wrong _UP, _OVER, _DOWN _HIT */ + +PHP_METHOD(swfbutton, addSound) +{ + zval *zsound; + long flags; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFSound sound; + SWFSoundInstance item; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zsound, &flags) == FAILURE) { + return; + } + + sound = getSound(zsound TSRMLS_CC); + item = SWFButton_addSound(button, sound, flags); + + if(item != NULL) { + /* try and create a soundinstance object */ + ret = zend_list_insert(item, le_swfsoundinstancep); + object_init_ex(return_value, soundinstance_class_entry_ptr); + add_property_resource(return_value, "soundinstance", ret); + zend_list_addref(ret); + } +} +/* }}} */ +#endif + +/* {{{ proto void swfbutton::addAction(object SWFAction, int flags) + Sets the action to perform when conditions described in flags is met */ +PHP_METHOD(swfbutton, addAction) +{ + zval *zaction; + long flags; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFAction action; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zaction, &flags) == FAILURE) { + return; + } + + action = getAction(zaction TSRMLS_CC); + SWFButton_addAction(button, action, flags); +} +/* }}} */ + +/* {{{ proto int ming_keypress(string str) + Returns the action flag for keyPress(char) */ +PHP_FUNCTION(ming_keypress) +{ + char *key; + int key_len; + char c; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + if (key_len > 1) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Only one character expected"); + } + + c = key[0]; + RETURN_LONG((c&0x7f)<<9); +} +/* }}} */ + +static zend_function_entry swfbutton_functions[] = { + PHP_ME(swfbutton, __construct, NULL, 0) + PHP_ME(swfbutton, setHit, NULL, 0) + PHP_ME(swfbutton, setOver, NULL, 0) + PHP_ME(swfbutton, setUp, NULL, 0) + PHP_ME(swfbutton, setDown, NULL, 0) + PHP_ME(swfbutton, setAction, NULL, 0) + PHP_ME(swfbutton, addShape, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swfbutton, setMenu, NULL, 0) + PHP_ME(swfbutton, setScalingGrid, NULL, 0) + PHP_ME(swfbutton, removeScalingGrid, NULL, 0) +#endif + PHP_ME(swfbutton, addAction, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swfbutton, addSound, NULL, 0) + PHP_ME(swfbutton, addCharacter, NULL, 0) +#endif + { NULL, NULL, NULL } +}; + +/* }}} */ + +/* {{{ SWFDisplayItem +*/ +/* {{{ internal function getDisplayItem + Returns the SWFDisplayItem contained in zval *id */ +static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC) +{ + void *item = SWFgetProperty(id, "displayitem", 11, le_swfdisplayitemp TSRMLS_CC); + + if (!item) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFDisplayItem"); + } + + return (SWFDisplayItem)item; +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::moveTo(double x, double y) + Moves this SWFDisplayItem to movie coordinates (x, y) */ +PHP_METHOD(swfdisplayitem, moveTo) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFDisplayItem_moveTo(getDisplayItem(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::move(double dx, double dy) + Displaces this SWFDisplayItem by (dx, dy) in movie coordinates */ +PHP_METHOD(swfdisplayitem, move) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFDisplayItem_move(getDisplayItem(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::scaleTo(double xScale [, double yScale]) + Scales this SWFDisplayItem by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ +PHP_METHOD(swfdisplayitem, scaleTo) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &x, &y) == FAILURE) { + return; + } + + if (ZEND_NUM_ARGS() == 1) { + y = x; + } + SWFDisplayItem_scaleTo(getDisplayItem(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::scale(double xScale, double yScale) + Multiplies this SWFDisplayItem's current x scale by xScale, its y scale by yScale */ +PHP_METHOD(swfdisplayitem, scale) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFDisplayItem_scale(getDisplayItem(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::rotateTo(double degrees) + Rotates this SWFDisplayItem the given (clockwise) degrees from its original orientation */ +PHP_METHOD(swfdisplayitem, rotateTo) +{ + double degrees; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) { + return; + } + + SWFDisplayItem_rotateTo(getDisplayItem(getThis() TSRMLS_CC), degrees); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::rotate(double degrees) + Rotates this SWFDisplayItem the given (clockwise) degrees from its current orientation */ +PHP_METHOD(swfdisplayitem, rotate) +{ + double degrees; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) { + return; + } + + SWFDisplayItem_rotate(getDisplayItem(getThis() TSRMLS_CC), degrees); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::skewXTo(double xSkew) + Sets this SWFDisplayItem's x skew value to xSkew */ +PHP_METHOD(swfdisplayitem, skewXTo) +{ + double x; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } + + SWFDisplayItem_skewXTo(getDisplayItem(getThis() TSRMLS_CC), x); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::skewX(double xSkew) + Adds xSkew to this SWFDisplayItem's x skew value */ +PHP_METHOD(swfdisplayitem, skewX) +{ + double x; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } + + SWFDisplayItem_skewX(getDisplayItem(getThis() TSRMLS_CC), x); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::skewYTo(double ySkew) + Sets this SWFDisplayItem's y skew value to ySkew */ +PHP_METHOD(swfdisplayitem, skewYTo) +{ + double y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } + + SWFDisplayItem_skewYTo(getDisplayItem(getThis() TSRMLS_CC), y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::skewY(double ySkew) + Adds ySkew to this SWFDisplayItem's y skew value */ +PHP_METHOD(swfdisplayitem, skewY) +{ + double y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } + + SWFDisplayItem_skewY(getDisplayItem(getThis() TSRMLS_CC), y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setMatrix(double a, double b, double c, double d, double x, double y) + Sets the item's transform matrix */ +PHP_METHOD(swfdisplayitem, setMatrix) +{ + double a, b, c, d, x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &a, &b, &c, &d, &x, &y) == FAILURE) { + return; + } + + SWFDisplayItem_setMatrix( getDisplayItem(getThis() TSRMLS_CC), a, b, c, d, x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setDepth(int depth) + Sets this SWFDisplayItem's z-depth to depth. Items with higher depth values are drawn on top of those with lower values */ +PHP_METHOD(swfdisplayitem, setDepth) +{ + long depth; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &depth) == FAILURE) { + return; + } + + SWFDisplayItem_setDepth(getDisplayItem(getThis() TSRMLS_CC), depth); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setRatio(float ratio) + Sets this SWFDisplayItem's ratio to ratio. Obviously only does anything if displayitem was created from an SWFMorph */ +PHP_METHOD(swfdisplayitem, setRatio) +{ + double ratio; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &ratio) == FAILURE) { + return; + } + + SWFDisplayItem_setRatio(getDisplayItem(getThis() TSRMLS_CC), ratio); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::addColor(int r, int g, int b [, int a]) + Sets the add color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 0 */ +PHP_METHOD(swfdisplayitem, addColor) +{ + long r, g, b, a = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; + } + + SWFDisplayItem_setColorAdd(getDisplayItem(getThis() TSRMLS_CC), r, g, b, (int)a); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::multColor(float r, float g, float b [, float a]) + Sets the multiply color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 1.0 */ +PHP_METHOD(swfdisplayitem, multColor) +{ + double r, g, b, a = 1.0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd|d", &r, &g, &b, &a) == FAILURE) { + return; + } + + SWFDisplayItem_setColorMult(getDisplayItem(getThis() TSRMLS_CC), r, g, b, a); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setName(string name) + Sets this SWFDisplayItem's name to name */ +PHP_METHOD(swfdisplayitem, setName) +{ + char *name; + int name_len; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + return; + } + + SWFDisplayItem_setName(item, name); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::addAction(object SWFAction, int flags) + Adds this SWFAction to the given SWFSprite instance */ +PHP_METHOD(swfdisplayitem, addAction) +{ + zval *zaction; + long flags; + SWFAction action; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zaction, &flags) == FAILURE) { + return; + } + + action = getAction(zaction TSRMLS_CC); + SWFDisplayItem_addAction(item, action, flags); +} +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ swfdisplayitem_remove */ + +PHP_METHOD(swfdisplayitem, remove) +{ + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_remove(item); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setMaskLevel(int level) + defines a MASK layer at level */ + +PHP_METHOD(swfdisplayitem, setMaskLevel) +{ + long level; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level) == FAILURE) { + return; + } + + SWFDisplayItem_setMaskLevel(getDisplayItem(getThis() TSRMLS_CC), level); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::endMask() + another way of defining a MASK layer */ + +PHP_METHOD(swfdisplayitem, endMask) +{ + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_endMask(item); +} +/* }}} */ + +/* {{{ swfdisplayitem_getX */ + +PHP_METHOD(swfdisplayitem, getX) +{ + double x, y; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getPosition(item, &x, &y); + RETURN_DOUBLE(x); +} +/* }}} */ + +/* {{{ swfdisplayitem_getY */ + +PHP_METHOD(swfdisplayitem, getY) +{ + double x, y; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getPosition(item, &x, &y); + RETURN_DOUBLE(y); +} +/* }}} */ + +/* {{{ swfdisplayitem_getXScale */ + +PHP_METHOD(swfdisplayitem, getXScale) +{ + double sx, sy; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getScale(item, &sx, &sy); + RETURN_DOUBLE(sx); +} +/* }}} */ + +/* {{{ swfdisplayitem_getYScale */ + +PHP_METHOD(swfdisplayitem, getYScale) +{ + double sx, sy; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getScale(item, &sx, &sy); + RETURN_DOUBLE(sy); +} +/* }}} */ + +/* {{{ swfdisplayitem_getXSkew */ + +PHP_METHOD(swfdisplayitem, getXSkew) +{ + double sx, sy; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getSkew(item, &sx, &sy); + RETURN_DOUBLE(sx); +} +/* }}} */ + +/* {{{ swfdisplayitem_getYSkew */ + +PHP_METHOD(swfdisplayitem, getYSkew) +{ + double sx, sy; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getSkew(item, &sx, &sy); + RETURN_DOUBLE(sy); +} +/* }}} */ + +/* {{{ swfdisplayitem_getRot */ + +PHP_METHOD(swfdisplayitem, getRot) +{ + double ret; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getRotation(item, &ret); + RETURN_DOUBLE(ret); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::cacheAsBitmap(int flag) + caches item as bitmap. can improve rendering speed */ + +PHP_METHOD(swfdisplayitem, cacheAsBitmap) +{ + long flag; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) { + return; + } + + SWFDisplayItem_cacheAsBitmap(getDisplayItem(getThis() TSRMLS_CC), flag); +} +/* }}} */ + + +/* {{{ proto void swfdisplayitem::setBlendMode(int mode) + adds blending to item */ +PHP_METHOD(swfdisplayitem, setBlendMode) +{ + long mode; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { + return; + } + + SWFDisplayItem_cacheAsBitmap(getDisplayItem(getThis() TSRMLS_CC), mode); +} +/* }}} */ + +/* {{{ proto int swfdisplayitem::setDepth() + gets the items depth */ +PHP_METHOD(swfdisplayitem, getDepth) +{ + int ret; + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + ret = SWFDisplayItem_getDepth(getDisplayItem(getThis() TSRMLS_CC)); + RETURN_LONG(ret); +} +/* }}} */ + +/* {{{ proto int swfdisplayitem::flush() */ +PHP_METHOD(swfdisplayitem, flush) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_flush(getDisplayItem(getThis() TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::addFilter(SWFFilter filter) */ +PHP_METHOD(swfdisplayitem, addFilter) +{ + zval *filter; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &filter) == FAILURE) { + return; + } + + SWFDisplayItem_addFilter(getDisplayItem(getThis() TSRMLS_CC), getFilter(filter TSRMLS_CC)); + +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setCXform(cx) */ +PHP_METHOD(swfdisplayitem, setCXform) +{ + zval *cx; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &cx) == FAILURE) { + return; + } + + SWFDisplayItem_setCXform(getDisplayItem(getThis() TSRMLS_CC), getCXform(cx TSRMLS_CC)); +} +/* }}} */ + +/** {{{ proto void swfdisplayitem::getMatrix() */ +PHP_METHOD(swfdisplayitem, getMatrix) +{ + SWFMatrix m; + int ret; + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + m = SWFDisplayItem_getMatrix(getDisplayItem(getThis() TSRMLS_CC)); + if(m != NULL) + { + ret = zend_list_insert(m, le_swfmatrixp); + object_init_ex(return_value, matrix_class_entry_ptr); + add_property_resource(return_value, "matrix", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +/** {{{ proto void swfdisplayitem::getCharacter() */ +PHP_METHOD(swfdisplayitem, getCharacter) +{ + SWFCharacter c; + int ret; + + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - convert_to_double_ex(ratio); - SWFDisplayItem_setRatio(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(ratio)); + c = SWFDisplayItem_getCharacter(getDisplayItem(getThis() TSRMLS_CC)); + if(c != NULL) + { + ret = zend_list_insert(c, le_swfcharacterp); + object_init_ex(return_value, character_class_entry_ptr); + add_property_resource(return_value, "character", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +#endif + +static zend_function_entry swfdisplayitem_functions[] = { + PHP_ME(swfdisplayitem, moveTo, NULL, 0) + PHP_ME(swfdisplayitem, move, NULL, 0) + PHP_ME(swfdisplayitem, scaleTo, NULL, 0) + PHP_ME(swfdisplayitem, scale, NULL, 0) + PHP_ME(swfdisplayitem, rotateTo, NULL, 0) + PHP_ME(swfdisplayitem, rotate, NULL, 0) + PHP_ME(swfdisplayitem, skewXTo, NULL, 0) + PHP_ME(swfdisplayitem, skewX, NULL, 0) + PHP_ME(swfdisplayitem, skewYTo, NULL, 0) + PHP_ME(swfdisplayitem, skewY, NULL, 0) + PHP_ME(swfdisplayitem, setMatrix, NULL, 0) + PHP_ME(swfdisplayitem, setDepth, NULL, 0) + PHP_ME(swfdisplayitem, setRatio, NULL, 0) + PHP_ME(swfdisplayitem, addColor, NULL, 0) + PHP_ME(swfdisplayitem, multColor, NULL, 0) + PHP_ME(swfdisplayitem, setName, NULL, 0) + PHP_ME(swfdisplayitem, addAction, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swfdisplayitem, remove, NULL, 0) + PHP_ME(swfdisplayitem, setMaskLevel,NULL, 0) + PHP_ME(swfdisplayitem, endMask, NULL, 0) + PHP_ME(swfdisplayitem, getX, NULL, 0) + PHP_ME(swfdisplayitem, getY, NULL, 0) + PHP_ME(swfdisplayitem, getXScale, NULL, 0) + PHP_ME(swfdisplayitem, getYScale, NULL, 0) + PHP_ME(swfdisplayitem, getXSkew, NULL, 0) + PHP_ME(swfdisplayitem, getYSkew, NULL, 0) + PHP_ME(swfdisplayitem, getRot, NULL, 0) + PHP_ME(swfdisplayitem, cacheAsBitmap, NULL, 0) + PHP_ME(swfdisplayitem, setBlendMode, NULL, 0) + PHP_ME(swfdisplayitem, getDepth, NULL, 0) + PHP_ME(swfdisplayitem, flush, NULL, 0) + PHP_ME(swfdisplayitem, addFilter, NULL, 0) + PHP_ME(swfdisplayitem, setCXform, NULL, 0) + PHP_ME(swfdisplayitem, getCharacter, NULL, 0) +#endif + { NULL, NULL, NULL } +}; + +/* }}} */ + +/* {{{ SWFFill +*/ +/* {{{ proto void swffill::__construct() + Creates a new SWFFill object */ +PHP_METHOD(swffill, __construct) +{ + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Instantiating SWFFill won't do any good- use SWFShape::addFill() instead"); +} + +static void destroy_SWFFill_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + /* this only destroys the shallow wrapper for SWFFillStyle, + which SWFShape destroys. So everything's okay. I hope. */ + + destroySWFFill((SWFFill)resource->ptr); +} +/* }}} */ + +/* {{{ internal function getFill + Returns the SWFFill object contained in zval *id */ +static SWFFill getFill(zval *id TSRMLS_DC) +{ + void *fill = SWFgetProperty(id, "fill", 4, le_swffillp TSRMLS_CC); + + if (!fill) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFill"); + } + return (SWFFill)fill; +} +/* }}} */ + +/* {{{ proto void swffill::moveTo(float x, float y) + Moves this SWFFill to shape coordinates (x,y) */ +PHP_METHOD(swffill, moveTo) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFFill_moveTo(getFill(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swffill::move(float dx, float dy) + Moves this SWFFill by (dx,dy) */ +PHP_METHOD(swffill, move) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFFill_move(getFill(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + + +/* {{{ proto void swffill::scaleTo(float xScale [, float yScale]) + Scales this SWFFill by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ +PHP_METHOD(swffill, scaleTo) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &x, &y) == FAILURE) { + return; + } + + if (ZEND_NUM_ARGS() == 1) { + y = x; + } + SWFFill_scaleXYTo(getFill(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swffill::scale(float xScale [, float yScale]) + Scales this SWFFill by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ +PHP_METHOD(swffill, scale) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &x, &y) == FAILURE) { + return; + } + + if (ZEND_NUM_ARGS() == 1) { + y = x; + } + SWFFill_scaleXY(getFill(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + + +/* {{{ proto void swffill::rotateTo(float degrees) + Rotates this SWFFill the given (clockwise) degrees from its original orientation */ +PHP_METHOD(swffill, rotateTo) +{ + double degrees; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) { + return; + } + + SWFFill_rotateTo(getFill(getThis() TSRMLS_CC), degrees); } /* }}} */ -/* {{{ proto void swfdisplayitem::addColor(int r, int g, int b [, int a]) - Sets the add color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 0 */ -PHP_METHOD(swfdisplayitem, addColor) +/* {{{ proto void swffill::rotate(float degrees) + Rotates this SWFFill the given (clockwise) degrees from its current orientation */ +PHP_METHOD(swffill, rotate) { - zval **r, **g, **b, **za; - int a = 0; + double degrees; - if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &za) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(za); - a = Z_LVAL_PP(za); - } else if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) { + return; } - - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - SWFDisplayItem_setColorAdd(getDisplayItem(getThis() TSRMLS_CC), Z_LVAL_PP(r), Z_LVAL_PP(g), Z_LVAL_PP(b), a); + SWFFill_rotate(getFill(getThis() TSRMLS_CC), degrees); } /* }}} */ -/* {{{ proto void swfdisplayitem::multColor(float r, float g, float b [, float a]) - Sets the multiply color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 1.0 */ -PHP_METHOD(swfdisplayitem, multColor) + +/* {{{ proto void swffill::skewXTo(float xSkew) + Sets this SWFFill's x skew value to xSkew */ +PHP_METHOD(swffill, skewXTo) { - zval **r, **g, **b, **za; - float a = 1.0f; + double x; - if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &za) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_double_ex(za); - a = FLOAT_Z_DVAL_PP(za); - } else if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; } - convert_to_double_ex(r); - convert_to_double_ex(g); - convert_to_double_ex(b); - - SWFDisplayItem_setColorMult(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(r), FLOAT_Z_DVAL_PP(g), FLOAT_Z_DVAL_PP(b), a); + SWFFill_skewXTo(getFill(getThis() TSRMLS_CC), x); } /* }}} */ -/* {{{ proto void swfdisplayitem::setName(string name) - Sets this SWFDisplayItem's name to name */ -PHP_METHOD(swfdisplayitem, setName) +/* {{{ proto void swffill::skewX(float xSkew) + Sets this SWFFill's x skew value to xSkew */ +PHP_METHOD(swffill, skewX) { - zval **name; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + double x; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &name) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; } - - convert_to_string_ex(name); - SWFDisplayItem_setName(item, Z_STRVAL_PP(name)); + + SWFFill_skewX(getFill(getThis() TSRMLS_CC), x); } /* }}} */ -/* {{{ proto void swfdisplayitem::addAction(object SWFAction, int flags) - Adds this SWFAction to the given SWFSprite instance */ -PHP_METHOD(swfdisplayitem, addAction) +/* {{{ proto void swffill::skewYTo(float ySkew) + Sets this SWFFill's y skew value to ySkew */ +PHP_METHOD(swffill, skewYTo) { - zval **zaction, **flags; - SWFAction action; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + double y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zaction, &flags) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; } - convert_to_object_ex(zaction); - convert_to_long_ex(flags); - action = getAction(*zaction TSRMLS_CC); - SWFDisplayItem_addAction(item, action, Z_LVAL_PP(flags)); + SWFFill_skewYTo(getFill(getThis() TSRMLS_CC), y); } /* }}} */ -#ifdef HAVE_NEW_MING -/* {{{ swfdisplayitem_remove */ - -PHP_METHOD(swfdisplayitem, remove) +/* {{{ proto void swffill::skewY(float ySkew) + Sets this SWFFill's y skew value to ySkew */ +PHP_METHOD(swffill, skewY) { - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + double y; - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } - SWFDisplayItem_remove(item); + SWFFill_skewY(getFill(getThis() TSRMLS_CC), y); } /* }}} */ -/* {{{ proto void swfdisplayitem::setMaskLevel(int level) - defines a MASK layer at level */ - -PHP_METHOD(swfdisplayitem, setMaskLevel) +/* {{{ proto void swffill::setMatrix(float a, float b, float c, float d, float x, float y) + Sets this SWFFill's y matrix values */ +PHP_METHOD(swffill, setMatrix) { - zval **level; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &level) == FAILURE) - WRONG_PARAM_COUNT; + double a, b, c, d, x, y; - convert_to_long_ex(level); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &a, &b, &c, &d, &x, &y) == FAILURE) { + return; + } - SWFDisplayItem_setMaskLevel(getDisplayItem(getThis() TSRMLS_CC), Z_LVAL_PP(level)); + SWFFill_setMatrix(getFill(getThis() TSRMLS_CC), a, b, c, d, x, y); } /* }}} */ -/* {{{ proto void swfdisplayitem::endMask() - another way of defining a MASK layer */ +static zend_function_entry swffill_functions[] = { + PHP_ME(swffill, __construct, NULL, 0) + PHP_ME(swffill, moveTo, NULL, 0) + PHP_ME(swffill, move, NULL, 0) + PHP_ME(swffill, scaleTo, NULL, 0) + PHP_ME(swffill, scale, NULL, 0) + PHP_ME(swffill, rotateTo, NULL, 0) + PHP_ME(swffill, rotate, NULL, 0) + PHP_ME(swffill, skewXTo, NULL, 0) + PHP_ME(swffill, skewX, NULL, 0) + PHP_ME(swffill, skewYTo, NULL, 0) + PHP_ME(swffill, skewY, NULL, 0) + PHP_ME(swffill, setMatrix, NULL, 0) + { NULL, NULL, NULL } +}; -PHP_METHOD(swfdisplayitem, endMask) +/* }}} */ + +/* {{{ SWFFontCharacter */ +#ifdef HAVE_NEW_MING + +/* {{{ internal function SWFText getFont(zval *id) + Returns the Font object in zval *id */ +static +SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC) { - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + void *font = SWFgetProperty(id, "fontcharacter", 13, le_swffontcharp TSRMLS_CC); - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if(!font) + php_error(E_ERROR, "called object is not an SWFFontCharacter!"); - SWFDisplayItem_endMask(item); + return (SWFFontCharacter)font; } /* }}} */ -/* {{{ swfdisplayitem_getX */ - -PHP_METHOD(swfdisplayitem, getX) +/* {{{ proto void swffontcha::raddChars(string) + adds characters to a font for exporting font */ +PHP_METHOD(swffontchar, addChars) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + char *string; + int string_len; - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } - ret = SWFDisplayItem_get_x(item); - RETURN_DOUBLE(ret); + SWFFontCharacter_addChars(getFontCharacter(getThis() TSRMLS_CC), string); } /* }}} */ -/* {{{ swfdisplayitem_getY */ +/* {{{ proto void swffontchar::addChars(string) + adds characters to a font for exporting font */ -PHP_METHOD(swfdisplayitem, getY) +PHP_METHOD(swffontchar, addUTF8Chars) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + char *string; + int string_len; - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } - ret = SWFDisplayItem_get_y(item); - RETURN_DOUBLE(ret); + SWFFontCharacter_addUTF8Chars(getFontCharacter(getThis() TSRMLS_CC), string); } /* }}} */ -/* {{{ swfdisplayitem_getXScale */ +/* {{{ proto void swffontchar::addAllChars() + * adds all characters to a font for exporting font */ -PHP_METHOD(swfdisplayitem, getXScale) +PHP_METHOD(swffontchar, addAllChars) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); - - if(ZEND_NUM_ARGS() != 0) + if (ZEND_NUM_ARGS() != 0 ) { WRONG_PARAM_COUNT; + } - ret = SWFDisplayItem_get_xScale(item); - RETURN_DOUBLE(ret); + SWFFontCharacter_addAllChars(getFontCharacter(getThis() TSRMLS_CC)); } /* }}} */ -/* {{{ swfdisplayitem_getYScale */ +static zend_function_entry swffontchar_functions[] = { + PHP_ME(swffontchar, addChars, NULL, 0) + PHP_ME(swffontchar, addUTF8Chars, NULL, 0) + PHP_ME(swffontchar, addAllChars, NULL, 0) + { NULL, NULL, NULL } +}; -PHP_METHOD(swfdisplayitem, getYScale) -{ - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); +#endif +/* }}} */ - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; +/* {{{ internal function SWFText getFont(zval *id) + Returns the Font object in zval *id */ +static SWFFont getFont(zval *id TSRMLS_DC) +{ + void *font = SWFgetProperty(id, "font", 4, le_swffontp TSRMLS_CC); - ret = SWFDisplayItem_get_yScale(item); - RETURN_DOUBLE(ret); + if (!font) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFont"); + } + return (SWFFont)font; } /* }}} */ -/* {{{ swfdisplayitem_getXSkew */ +/* {{{ proto void swffont::__construct(string filename) + Creates a new SWFFont object from given file */ +PHP_METHOD(swffont, __construct) +{ + char *file; + int file_len; + SWFFont font; + int ret; -PHP_METHOD(swfdisplayitem, getXSkew) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) { + return; + } + + PHP_MING_FILE_CHK(file); + font = newSWFFont_fromFile(file); + + if(font == NULL) + { + php_error(E_ERROR, "Loading font \"%s\" failed! " + "Please use new SWFBrowserFont(\"%s\") " + "for player/browser fonts.", file, file); + + } + + if(font) + { + ret = zend_list_insert(font, le_swffontp); + object_init_ex(getThis(), font_class_entry_ptr); + add_property_resource(getThis(), "font", ret); + zend_list_addref(ret); + } +} + +static void destroy_SWFFont_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + destroySWFBlock((SWFBlock)resource->ptr); +} +/* }}} */ - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; +/* {{{ proto float swffont::getWidth(string str) + Calculates the width of the given string in this font at full height */ +PHP_METHOD(swffont, getWidth) +{ + char *string; + int string_len; + float width; - ret = SWFDisplayItem_get_xSkew(item); - RETURN_DOUBLE(ret); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } + + width = SWFFont_getStringWidth(getFont(getThis() TSRMLS_CC), string); + RETURN_DOUBLE(width); } /* }}} */ -/* {{{ swfdisplayitem_getYSkew */ +#ifdef HAVE_NEW_MING +/* {{{ proto int swffont::getUTF8Width(string) + Calculates the width of the given string in this font at full height */ -PHP_METHOD(swfdisplayitem, getYSkew) +PHP_METHOD(swffont, getUTF8Width) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + char *string; + int string_len; + float width; - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } - ret = SWFDisplayItem_get_ySkew(item); - RETURN_DOUBLE(ret); + width = SWFFont_getUTF8StringWidth(getFont(getThis() TSRMLS_CC), string); + RETURN_DOUBLE(width); +} + +/* {{{ proto int swffont::getglyphcount() */ +PHP_METHOD(swffont, getGlyphCount) +{ + RETURN_LONG(SWFFont_getGlyphCount(getFont(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ swfdisplayitem_getRot */ +/* {{{ proto string swffont::getname() */ +PHP_METHOD(swffont, getName) +{ + RETURN_STRING(SWFFont_getName(getFont(getThis() TSRMLS_CC)), 0); +} +/* }}} */ +#endif -PHP_METHOD(swfdisplayitem, getRot) +/* {{{ proto float swffont::getAscent() + Returns the ascent of the font, or 0 if not available */ +PHP_METHOD(swffont, getAscent) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + RETURN_DOUBLE(SWFFont_getAscent(getFont(getThis() TSRMLS_CC))); +} +/* }}} */ - if(ZEND_NUM_ARGS() != 0) +/* {{{ proto float swffont::getDescent() + Returns the descent of the font, or 0 if not available */ +PHP_METHOD(swffont, getDescent) +{ + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; + } + RETURN_DOUBLE(SWFFont_getDescent(getFont(getThis() TSRMLS_CC))); +} +/* }}} */ - ret = SWFDisplayItem_get_rot(item); - RETURN_DOUBLE(ret); +/* {{{ proto float swffont::getLeading() + Returns the leading of the font, or 0 if not available */ +PHP_METHOD(swffont, getLeading) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + RETURN_DOUBLE(SWFFont_getLeading(getFont(getThis() TSRMLS_CC))); } /* }}} */ -#endif -static zend_function_entry swfdisplayitem_functions[] = { - PHP_ME(swfdisplayitem, moveTo, NULL, 0) - PHP_ME(swfdisplayitem, move, NULL, 0) - PHP_ME(swfdisplayitem, scaleTo, NULL, 0) - PHP_ME(swfdisplayitem, scale, NULL, 0) - PHP_ME(swfdisplayitem, rotateTo, NULL, 0) - PHP_ME(swfdisplayitem, rotate, NULL, 0) - PHP_ME(swfdisplayitem, skewXTo, NULL, 0) - PHP_ME(swfdisplayitem, skewX, NULL, 0) - PHP_ME(swfdisplayitem, skewYTo, NULL, 0) - PHP_ME(swfdisplayitem, skewY, NULL, 0) - PHP_ME(swfdisplayitem, setMatrix, NULL, 0) - PHP_ME(swfdisplayitem, setDepth, NULL, 0) - PHP_ME(swfdisplayitem, setRatio, NULL, 0) - PHP_ME(swfdisplayitem, addColor, NULL, 0) - PHP_ME(swfdisplayitem, multColor, NULL, 0) - PHP_ME(swfdisplayitem, setName, NULL, 0) - PHP_ME(swfdisplayitem, addAction, NULL, 0) +/* {{{ proto string swffont::getShape(code) +Returns the glyph shape of a char as a text string */ +PHP_METHOD(swffont, getShape) +{ + int zcode; + char *result; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &zcode) == FAILURE) + WRONG_PARAM_COUNT; + + result = SWFFont_getShape(getFont(getThis() TSRMLS_CC), zcode); + RETURN_STRING(result, 1); + free(result); +} +/* }}} */ + +static zend_function_entry swffont_functions[] = { + PHP_ME(swffont, __construct, NULL, 0) + PHP_ME(swffont, getWidth, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swffont, getUTF8Width, NULL, 0) +#endif + PHP_ME(swffont, getAscent, NULL, 0) + PHP_ME(swffont, getDescent, NULL, 0) + PHP_ME(swffont, getLeading, NULL, 0) #ifdef HAVE_NEW_MING - PHP_ME(swfdisplayitem, remove, NULL, 0) - PHP_ME(swfdisplayitem, setMaskLevel,NULL, 0) - PHP_ME(swfdisplayitem, endMask, NULL, 0) - PHP_ME(swfdisplayitem, getX, NULL, 0) - PHP_ME(swfdisplayitem, getY, NULL, 0) - PHP_ME(swfdisplayitem, getXScale, NULL, 0) - PHP_ME(swfdisplayitem, getYScale, NULL, 0) - PHP_ME(swfdisplayitem, getXSkew, NULL, 0) - PHP_ME(swfdisplayitem, getYSkew, NULL, 0) - PHP_ME(swfdisplayitem, getRot, NULL, 0) + PHP_ME(swffont, getGlyphCount, NULL, 0) + PHP_ME(swffont, getName, NULL, 0) #endif + PHP_ME(swffont, getShape, NULL, 0) { NULL, NULL, NULL } }; /* }}} */ -/* {{{ SWFFill +/* {{{ SWFFilterMatrix */ -/* {{{ proto void swffill::__construct() - Creates a new SWFFill object */ -PHP_METHOD(swffill, __construct) -{ - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Instantiating SWFFill won't do any good- use SWFShape::addFill() instead"); +/* {{{ proto void swffiltermatrix::__construct(cols, rows, array:vals) + Creates a new SWFFilterMatrix object */ +PHP_METHOD(swffiltermatrix, __construct) +{ + long cols, rows; + zval *vals, **data; + SWFFilterMatrix matrix; + HashTable *arr_hash; + int ret, items, i; + float *values; + HashPosition pointer; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla", &cols, &rows, &vals) == FAILURE) { + return; + } + + arr_hash = Z_ARRVAL_P(vals); + items = zend_hash_num_elements(arr_hash); + if(items != cols * rows) + { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Can't create FilterMatrix." + "Not enough / too many items it array"); + } + values = (float *)malloc(items * sizeof(float)); + for(i = 0, zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); + zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; + zend_hash_move_forward_ex(arr_hash, &pointer), i++) + { + zval temp; + temp = **data; + zval_copy_ctor(&temp); + convert_to_double(&temp); + values[i] = Z_DVAL(temp); + zval_dtor(&temp); + } + + matrix = newSWFFilterMatrix(cols, rows, values); + free(values); /* array is copied by libming */ + ret = zend_list_insert(matrix, le_swffiltermatrixp); + object_init_ex(getThis(), filtermatrix_class_entry_ptr); + add_property_resource(getThis(), "filtermatrix", ret); + zend_list_addref(ret); } -static void destroy_SWFFill_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +static void destroy_SWFFilterMatrix_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - /* this only destroys the shallow wrapper for SWFFillStyle, - which SWFShape destroys. So everything's okay. I hope. */ - - destroySWFFill((SWFFill)resource->ptr); + destroySWFFilterMatrix((SWFFilterMatrix)resource->ptr); } /* }}} */ -/* {{{ internal function getFill - Returns the SWFFill object contained in zval *id */ -static SWFFill getFill(zval *id TSRMLS_DC) +/* {{{ internal function getFilterMatrix + Returns the SWFFilterMatrix object contained in zval *id */ +static SWFFilterMatrix getFilterMatrix(zval *id TSRMLS_DC) { - void *fill = SWFgetProperty(id, "fill", 4, le_swffillp TSRMLS_CC); + void *matrix = SWFgetProperty(id, "filtermatrix", strlen("filtermatrix"), le_swffiltermatrixp TSRMLS_CC); - if (!fill) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFFill"); + if (!matrix) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFilterMatrix"); } - return (SWFFill)fill; + return (SWFFilterMatrix)matrix; } /* }}} */ +static zend_function_entry swffiltermatrix_functions[] = { + PHP_ME(swffiltermatrix, __construct, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ -/* {{{ proto void swffill::moveTo(float x, float y) - Moves this SWFFill to shape coordinates (x,y) */ -PHP_METHOD(swffill, moveTo) +/* {{{ SWFShadow +*/ +/* {{{ proto void swfshadow::__construct(angle, distance, strength) + Creates a new SWFShadow object */ +PHP_METHOD(swfshadow, __construct) { - zval **x, **y; + double angle, distance, strength; + SWFShadow shadow; + int ret; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &angle, &distance, &strength) == FAILURE) { + return; } - - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFFill_moveTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + shadow = newSWFShadow(angle, distance, strength); + ret = zend_list_insert(shadow, le_swfshadowp); + object_init_ex(getThis(), shadow_class_entry_ptr); + add_property_resource(getThis(), "shadow", ret); + zend_list_addref(ret); } -/* }}} */ -/* {{{ proto void swffill::scaleTo(float xScale [, float yScale]) - Scales this SWFFill by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ -PHP_METHOD(swffill, scaleTo) +static void destroy_SWFShadow_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - zval **x, **y; - - if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_double_ex(x); - SWFFill_scaleXYTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(x)); - } else if (ZEND_NUM_ARGS() == 2) { - if (zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFFill_scaleXYTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); - } else { - WRONG_PARAM_COUNT; - } + destroySWFShadow((SWFShadow)resource->ptr); } /* }}} */ -/* {{{ proto void swffill::rotateTo(float degrees) - Rotates this SWFFill the given (clockwise) degrees from its original orientation */ -PHP_METHOD(swffill, rotateTo) +/* {{{ internal function getShadow + Returns the SWFShadow object contained in zval *id */ +static SWFShadow getShadow(zval *id TSRMLS_DC) { - zval **degrees; + void *shadow = SWFgetProperty(id, "shadow", strlen("shadow"), le_swfshadowp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, °rees) == FAILURE) { - WRONG_PARAM_COUNT; + if (!shadow) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFShadow"); } - convert_to_double_ex(degrees); - SWFFill_rotateTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(degrees)); + return (SWFShadow)shadow; } /* }}} */ +static zend_function_entry swfshadow_functions[] = { + PHP_ME(swfshadow, __construct, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ -/* {{{ proto void swffill::skewXTo(float xSkew) - Sets this SWFFill's x skew value to xSkew */ -PHP_METHOD(swffill, skewXTo) -{ - zval **x; +/* {{{ SWFBlur +*/ +/* {{{ proto void swfblur::__construct(blurX, blurY, passes) + Creates a new SWFBlur object */ +PHP_METHOD(swfblur, __construct) +{ + double blurX, blurY; + long passes; + SWFBlur blur; + int ret; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddl", &blurX, &blurY, &passes) == FAILURE) { + return; } - convert_to_double_ex(x); - SWFFill_skewXTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x)); + + blur = newSWFBlur(blurX, blurY, passes); + ret = zend_list_insert(blur, le_swfblurp); + object_init_ex(getThis(), blur_class_entry_ptr); + add_property_resource(getThis(), "blur", ret); + zend_list_addref(ret); +} + +static void destroy_SWFBlur_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFBlur((SWFBlur)resource->ptr); } /* }}} */ -/* {{{ proto void swffill::skewYTo(float ySkew) - Sets this SWFFill's y skew value to ySkew */ -PHP_METHOD(swffill, skewYTo) +/* {{{ internal function getBlur + Returns the SWFBlur object contained in zval *id */ +static SWFBlur getBlur(zval *id TSRMLS_DC) { - zval **y; + void *blur = SWFgetProperty(id, "blur", strlen("blur"), le_swfblurp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (!blur) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFBlur"); } - convert_to_double_ex(y); - SWFFill_skewYTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(y)); + return (SWFBlur)blur; } /* }}} */ -static zend_function_entry swffill_functions[] = { - PHP_ME(swffill, __construct, NULL, 0) - PHP_ME(swffill, moveTo, NULL, 0) - PHP_ME(swffill, scaleTo, NULL, 0) - PHP_ME(swffill, rotateTo, NULL, 0) - PHP_ME(swffill, skewXTo, NULL, 0) - PHP_ME(swffill, skewYTo, NULL, 0) +static zend_function_entry swfblur_functions[] = { + PHP_ME(swfblur, __construct, NULL, 0) { NULL, NULL, NULL } }; - /* }}} */ -/* {{{ SWFFontCharacter */ -#ifdef HAVE_NEW_MING - -/* {{{ internal function SWFText getFont(zval *id) - Returns the Font object in zval *id */ -static -SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC) +/* {{{ SWFGradient +*/ +/* {{{ proto void swfgradient::__construct() + Creates a new SWFGradient object */ +PHP_METHOD(swfgradient, __construct) { - void *font = SWFgetProperty(id, "fontcharacter", 13, le_swffontcharp TSRMLS_CC); - - if(!font) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFFontCharacter!"); + SWFGradient gradient = newSWFGradient(); + int ret = zend_list_insert(gradient, le_swfgradientp); - return (SWFFontCharacter)font; + object_init_ex(getThis(), gradient_class_entry_ptr); + add_property_resource(getThis(), "gradient", ret); + zend_list_addref(ret); } -/* }}} */ -static void destroy_SWFFontCharacter_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +static void destroy_SWFGradient_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - destroySWFBlock((SWFBlock)resource->ptr); + destroySWFGradient((SWFGradient)resource->ptr); } +/* }}} */ -/* {{{ proto void swffontcha::raddChars(string) - adds characters to a font for exporting font */ -PHP_METHOD(swffontchar, addChars) +/* {{{ internal function getGradient + Returns the SWFGradient object contained in zval *id */ +static SWFGradient getGradient(zval *id TSRMLS_DC) { - zval **zstring; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(zstring); + void *gradient = SWFgetProperty(id, "gradient", 8, le_swfgradientp TSRMLS_CC); - SWFFontCharacter_addChars(getFontCharacter(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + if (!gradient) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFGradient"); + } + return (SWFGradient)gradient; } /* }}} */ -/* {{{ proto void swffontchar::addChars(string) - adds characters to a font for exporting font */ - -PHP_METHOD(swffontchar, addUTF8Chars) +/* {{{ proto void swfgradient::addEntry(float ratio, int r, int g, int b [, int a]) + Adds given entry to the gradient */ +PHP_METHOD(swfgradient, addEntry) { - zval **zstring; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; + double ratio; + long r, g, b, a = 0xff; - convert_to_string_ex(zstring); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dlll|l", &ratio, &r, &g, &b, &a) == FAILURE) { + return; + } - SWFFontCharacter_addUTF8Chars(getFontCharacter(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + SWFGradient_addEntry( getGradient(getThis() TSRMLS_CC), ratio, (byte)r, (byte)g, (byte)b, (byte)a); } /* }}} */ -static zend_function_entry swffontchar_functions[] = { - PHP_ME(swffontchar, addChars, NULL, 0) - PHP_ME(swffontchar, addUTF8Chars, NULL, 0) - { NULL, NULL, NULL } -}; - -#endif -/* }}} */ - -/* {{{ SWFFont +/* {{{ proto void swfgradient::setSpreadMode(mode) + supported mode values: + * SWF_GRADIENT_PAD + * SWF_GRADIENT_REFLECT + * SWF_GRADIENT_REPEAT */ -/* {{{ internal function SWFText getFont(zval *id) - Returns the Font object in zval *id */ -static SWFFont getFont(zval *id TSRMLS_DC) +PHP_METHOD(swfgradient, setSpreadMode) { - void *font = SWFgetProperty(id, "font", 4, le_swffontp TSRMLS_CC); + long val; - if (!font) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFFont"); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { + return; } - return (SWFFont)font; + + SWFGradient_setSpreadMode(getGradient(getThis() TSRMLS_CC), val); } /* }}} */ -/* {{{ proto void swffont::__construct(string filename) - Creates a new SWFFont object from given file */ -PHP_METHOD(swffont, __construct) +/* {{{ proto void swfgradient::setInterpolationMode(mode) + * supported mode values: + * SWF_GRADIENT_NORMAL + * SWF_GRADIENT_LINEAR +*/ +PHP_METHOD(swfgradient, setInterpolationMode) { - zval **zfile; - SWFFont font; - int ret; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfile) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(zfile); - - if (strcmp(Z_STRVAL_PP(zfile)+Z_STRLEN_PP(zfile)-4, ".fdb") == 0) { - php_stream * stream; - FILE * file; - - stream = php_stream_open_wrapper(Z_STRVAL_PP(zfile), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); - - if (stream == NULL) { - RETURN_FALSE; - } + long val; - if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void*)&file, REPORT_ERRORS)) { - php_stream_close(stream); - RETURN_FALSE; - } - - font = loadSWFFontFromFile(file); - php_stream_close(stream); - } else { - PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile)); - font = (SWFFont)newSWFBrowserFont(Z_STRVAL_PP(zfile)); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { + return; } - ret = zend_list_insert(font, le_swffontp); - - object_init_ex(getThis(), font_class_entry_ptr); - add_property_resource(getThis(), "font", ret); - zend_list_addref(ret); -} - -static void destroy_SWFFont_resource(zend_rsrc_list_entry *resource TSRMLS_DC) -{ - destroySWFBlock((SWFBlock)resource->ptr); + SWFGradient_setInterpolationMode(getGradient(getThis() TSRMLS_CC), val); } /* }}} */ -/* {{{ proto float swffont::getWidth(string str) - Calculates the width of the given string in this font at full height */ -PHP_METHOD(swffont, getWidth) +/* {{{ proto void swfgradient::setFocalPoint(mode) */ +PHP_METHOD(swfgradient, setFocalPoint) { - zval **zstring; - float width; + long val; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { + return; } - convert_to_string_ex(zstring); - width = SWFFont_getStringWidth(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); - RETURN_DOUBLE(width); + + SWFGradient_setFocalPoint(getGradient(getThis() TSRMLS_CC), val); } /* }}} */ -#ifdef HAVE_NEW_MING -/* {{{ proto int swffont::getUTF8Width(string) - Calculates the width of the given string in this font at full height */ - -PHP_METHOD(swffont, getUTF8Width) -{ - zval **zstring; - float width; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(zstring); +static zend_function_entry swfgradient_functions[] = { + PHP_ME(swfgradient, __construct, NULL, 0) + PHP_ME(swfgradient, addEntry, NULL, 0) + PHP_ME(swfgradient, setSpreadMode, NULL, 0) + PHP_ME(swfgradient, setInterpolationMode, NULL, 0) + PHP_ME(swfgradient, setFocalPoint, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ - width = SWFFont_getUTF8StringWidth(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); +/* {{{ SWFFilter +*/ - RETURN_DOUBLE(width); +/* helper functions */ +static SWFColor hashToColor(zval **colorHash TSRMLS_DC) +{ + zval **data; + HashPosition pointer; + HashTable *arr_hash; + SWFColor c; + + c.alpha = 0xff; + c.red = 0; + c.green = 0; + c.blue = 0; + + arr_hash = Z_ARRVAL_PP(colorHash); + if(zend_hash_num_elements(arr_hash) < 3 || zend_hash_num_elements(arr_hash) > 4) + php_error_docref(NULL TSRMLS_CC, E_ERROR, "not a valid colorHash\n"); + + for(zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); + zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; + zend_hash_move_forward_ex(arr_hash, &pointer)) + { + zval temp; + char *key; + unsigned int key_len; + unsigned long index; + + temp = **data; + if (zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer) + == HASH_KEY_IS_STRING) + { + zval_copy_ctor(&temp); + convert_to_long(&temp); + if(strcmp(key, "red") == 0) + c.red = Z_LVAL(temp); + else if (strcmp(key, "green") == 0) + c.green = Z_LVAL(temp); + else if (strcmp(key, "blue") == 0) + c.blue = Z_LVAL(temp); + else if (strcmp(key, "alpha") == 0) + c.alpha = Z_LVAL(temp); + else + php_error_docref(NULL TSRMLS_CC, E_ERROR, "not a valid colorHash\n"); + + zval_dtor(&temp); + } + } + return c; } -/* }}} */ -/* not sure about 0 bytes !!!!!!!!! */ -/* {{{ proto int swffont::getWideWidth(string) - Calculates the width of the given string in this font at full height */ -/* -PHP_METHOD(swffont, getWideWidth) +static SWFFilter createDropShadowFilter(int argc, zval **argv[] TSRMLS_DC) { - zval **zstring; - float width; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; + zval **colorHash, **blur, **shadow, **flags; + SWFColor c; + + if(argc != 5) + return NULL; - convert_to_string_ex(zstring); + colorHash = argv[1]; + convert_to_array_ex(colorHash); + c = hashToColor(colorHash TSRMLS_CC); + + blur = argv[2]; + convert_to_object_ex(blur); + + shadow = argv[3]; + convert_to_object_ex(shadow); - width = SWFFont_getWideStringWidth(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + flags = argv[4]; + convert_to_long_ex(flags); - RETURN_DOUBLE(width); + return newDropShadowFilter(c, getBlur(*blur TSRMLS_CC), + getShadow(*shadow TSRMLS_CC), Z_LVAL_PP(flags)); } -*/ -/* }}} */ -#endif -/* {{{ proto float swffont::getAscent() - Returns the ascent of the font, or 0 if not available */ -PHP_METHOD(swffont, getAscent) +static SWFFilter createBlurFilter(int argc, zval **argv[] TSRMLS_DC) { - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } - RETURN_DOUBLE(SWFFont_getAscent(getFont(getThis() TSRMLS_CC))); + zval **blur; + + if(argc != 2) + return NULL; + + blur = argv[1]; + convert_to_object_ex(blur); + + return newBlurFilter(getBlur(*blur TSRMLS_CC)); } -/* }}} */ -/* {{{ proto float swffont::getDescent() - Returns the descent of the font, or 0 if not available */ -PHP_METHOD(swffont, getDescent) +static SWFFilter createGlowFilter(int argc, zval **argv[] TSRMLS_DC) { - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } - RETURN_DOUBLE(SWFFont_getDescent(getFont(getThis() TSRMLS_CC))); + zval **color, **blur, **strength, **flags; + SWFColor c; + + if(argc != 5) + return NULL; + + color = argv[1]; + convert_to_array_ex(color); + c = hashToColor(color TSRMLS_CC); + + blur = argv[2]; + convert_to_object_ex(blur); + + strength = argv[3]; + convert_to_double_ex(strength); + + flags = argv[4]; + convert_to_long_ex(flags); + + return newGlowFilter(c, getBlur(*blur TSRMLS_CC), + Z_DVAL_PP(strength), Z_LVAL_PP(flags)); } -/* }}} */ -/* {{{ proto float swffont::getLeading() - Returns the leading of the font, or 0 if not available */ -PHP_METHOD(swffont, getLeading) +static SWFFilter createBevelFilter(int argc, zval **argv[] TSRMLS_DC) { - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } - RETURN_DOUBLE(SWFFont_getLeading(getFont(getThis() TSRMLS_CC))); + zval **sColor, **hColor, **blur, **shadow, **flags; + SWFColor hc, sc; + + if(argc != 6) + return NULL; + + sColor = argv[1]; + convert_to_array_ex(sColor); + sc = hashToColor(sColor TSRMLS_CC); + + hColor = argv[2]; + convert_to_array_ex(hColor); + hc = hashToColor(hColor TSRMLS_CC); + + blur = argv[3]; + convert_to_object_ex(blur); + + shadow = argv[4]; + convert_to_object_ex(shadow); + + flags = argv[5]; + convert_to_long_ex(flags); + + return newBevelFilter(sc, hc, getBlur(*blur TSRMLS_CC), + getShadow(*shadow TSRMLS_CC), Z_LVAL_PP(flags)); } -/* }}} */ -#ifdef HAVE_NEW_MING -/* {{{ proto void swffont::addChars(string) - adds characters to a font required within textfields */ -/* -PHP_METHOD(swffont, addChars) +static SWFFilter createGradientGlowFilter(int argc, zval **argv[] TSRMLS_DC) { - zval **zstring; + zval **gradient, **blur, **shadow, **flags; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; + if(argc != 5) + return NULL; + + gradient = argv[1]; + convert_to_object_ex(gradient); + + blur = argv[2]; + convert_to_object_ex(blur); + + shadow = argv[3]; + convert_to_object_ex(shadow); - convert_to_string_ex(zstring); + flags = argv[4]; + convert_to_long_ex(flags); - SWFFont_addChars(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + return newGradientGlowFilter(getGradient(*gradient TSRMLS_CC), + getBlur(*blur TSRMLS_CC), getShadow(*shadow TSRMLS_CC), + Z_LVAL_PP(flags)); } -*/ -/* }}} */ -/* {{{ proto string swffont::getShape(code) - Returns the glyph shape of a char as a text string */ -PHP_METHOD(swffont, getShape) +static SWFFilter createConvolutionFilter(int argc, zval **argv[] TSRMLS_DC) { - zval **zcode; - char *result; + zval **matrix, **div, **bias, **color, **flags; + SWFColor c; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zcode) == FAILURE) - WRONG_PARAM_COUNT; + if(argc != 6) + return NULL; - convert_to_long_ex(zcode); + matrix = argv[1]; + convert_to_object_ex(matrix); - result = SWFFont_getShape(getFont(getThis() TSRMLS_CC), Z_LVAL_PP(zcode)); - RETVAL_STRING(result, 1); - free(result); -} -/* }}} */ + div = argv[2]; + convert_to_double_ex(div); -#endif + bias = argv[3]; + convert_to_double_ex(bias); -static zend_function_entry swffont_functions[] = { - PHP_ME(swffont, __construct, NULL, 0) - PHP_ME(swffont, getWidth, NULL, 0) -#ifdef HAVE_NEW_MING - PHP_ME(swffont, getUTF8Width, NULL, 0) -/* PHP_ME(swffont, getwidewidth, NULL, 0)*/ -#endif - PHP_ME(swffont, getAscent, NULL, 0) - PHP_ME(swffont, getDescent, NULL, 0) - PHP_ME(swffont, getLeading, NULL, 0) -#ifdef HAVE_NEW_MING -/* PHP_ME(swffont, addchars, NULL, 0)*/ - PHP_ME(swffont, getShape, NULL, 0) -#endif - { NULL, NULL, NULL } -}; + color = argv[4]; + convert_to_array_ex(color); + c = hashToColor(color TSRMLS_CC); -/* }}} */ + flags = argv[5]; + convert_to_long_ex(flags); + + return newConvolutionFilter(getFilterMatrix(*matrix TSRMLS_CC), Z_DVAL_PP(div), + Z_DVAL_PP(bias), c, Z_LVAL_PP(flags)); +} -/* {{{ SWFGradient -*/ -/* {{{ proto void swfgradient::__construct() - Creates a new SWFGradient object */ -PHP_METHOD(swfgradient, __construct) +static SWFFilter createColorMatrixFilter(int argc, zval **argv[] TSRMLS_DC) { - SWFGradient gradient = newSWFGradient(); - int ret = zend_list_insert(gradient, le_swfgradientp); + zval **matrix; - object_init_ex(getThis(), gradient_class_entry_ptr); - add_property_resource(getThis(), "gradient", ret); - zend_list_addref(ret); + if(argc != 2) + return NULL; + + matrix = argv[1]; + convert_to_object_ex(matrix); + + return newColorMatrixFilter(getFilterMatrix(*matrix TSRMLS_CC)); } -static void destroy_SWFGradient_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +static SWFFilter createGradientBevelFilter(int argc, zval **argv[] TSRMLS_DC) { - destroySWFGradient((SWFGradient)resource->ptr); -} -/* }}} */ + zval **gradient, **blur, **shadow, **flags; -/* {{{ internal function getGradient - Returns the SWFGradient object contained in zval *id */ -static SWFGradient getGradient(zval *id TSRMLS_DC) + if(argc != 5) + return NULL; + + gradient = argv[1]; + convert_to_object_ex(gradient); + + blur = argv[2]; + convert_to_object_ex(blur); + + shadow = argv[3]; + convert_to_object_ex(shadow); + + flags = argv[4]; + convert_to_long_ex(flags); + + return newGradientBevelFilter(getGradient(*gradient TSRMLS_CC), + getBlur(*blur TSRMLS_CC), getShadow(*shadow TSRMLS_CC), + Z_LVAL_PP(flags)); +} + +/* {{{ proto void swffilter::__construct(type, ...) + Creates a new SWFFilter object: + + Supported filter types: + * SWFFILTER_TYPE_DROPSHADOW + new SWFFilter(SWFFILTER_TYPE_DROPSHADOW, colorHash, blur, shadow, flags); + * SWFFILTER_TYPE_BLUR + new SWFFilter(SWFFILTER_TYPE_BLUR, blur); + * SWFFILTER_TYPE_GLOW + new SWFFilter(SWFFILTER_TYPE_GLOW, colorHash, blur, strenght:float, flags); + * SWFFILTER_TYPE_BEVEL + new SWFFilter(SWFFILTER_TYPE_BEVEL, colorHash_shadow, colorHash_highlight, blur, shadow, flags); + * SWFFILTER_TYPE_GRADIENTGLOW + new SWFFilter(SWFFILTER_TYPE_GRADIENTGLOW, gradient, blur, shadow, flags); + * SWFFILTER_TYPE_CONVOLUTION + new SWFFilter(SWFFILTER_TYPE_CONVOLUTION, filterMatrix, divisor:float, bias:float, colorHash, flags); + * SWFFILTER_TYPE_COLORMATRIX + new SWFFilter(SWFFILTER_TYPE_COLORMATRIX, filterMatrix); + * SWFFILTER_TYPE_GRADIENTBEVEL + new SWFFilter(SWFFILTER_TYPE_GRADIENTBEVEL, gradient, blur, shadow, flags); + + Supported flags are: + * SWFFILTER_FLAG_CLAMP + * SWFFILTER_FLAG_PRESERVE_ALPHA + * SWFFILTER_MODE_INNER + * SWFFILTER_MODE_KO + + A colorHash must have the following entries: + 'red' => 0...255, + 'green' => 0...255, + 'blue' => 0...255, + 'alpha' => 0...255 (optional) +*/ +PHP_METHOD(swffilter, __construct) { - void *gradient = SWFgetProperty(id, "gradient", 8, le_swfgradientp TSRMLS_CC); + zval **argv[6]; + int argc = ZEND_NUM_ARGS(); + int type, ret; + SWFFilter filter = NULL; + + if (argc > 6 || argc < 2 || zend_get_parameters_array_ex(argc, argv) == FAILURE) + WRONG_PARAM_COUNT; + - if (!gradient) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFGradient"); + convert_to_long_ex(argv[0]); + type = Z_LVAL_PP(argv[0]); + switch(type) + { + case SWFFILTER_TYPE_DROPSHADOW: + filter = createDropShadowFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_BLUR: + filter = createBlurFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_GLOW: + filter = createGlowFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_BEVEL: + filter = createBevelFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_GRADIENTGLOW: + filter = createGradientGlowFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_CONVOLUTION: + filter = createConvolutionFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_COLORMATRIX: + filter = createColorMatrixFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_GRADIENTBEVEL: + filter = createGradientBevelFilter(argc, argv TSRMLS_CC); + break; + default: + php_error_docref(NULL TSRMLS_CC, E_ERROR, "new SWFFilter: unknown type"); } - return (SWFGradient)gradient; + + if(filter == NULL) + WRONG_PARAM_COUNT; + + ret = zend_list_insert(filter, le_swffilterp); + object_init_ex(getThis(), filter_class_entry_ptr); + add_property_resource(getThis(), "filter", ret); + zend_list_addref(ret); } /* }}} */ -/* {{{ proto void swfgradient::addEntry(float ratio, int r, int g, int b [, int a]) - Adds given entry to the gradient */ -PHP_METHOD(swfgradient, addEntry) +/* {{{ internal function getFilter + Returns the SWFFilter object contained in zval *id */ +static SWFFilter getFilter(zval *id TSRMLS_DC) { - zval **ratio, **r, **g, **b; - byte a = 0xff; - - if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &ratio, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 5) { - zval **za; + void *filter = SWFgetProperty(id, "filter", + strlen("filter"), le_swffilterp TSRMLS_CC); - if (zend_get_parameters_ex(5, &ratio, &r, &g, &b, &za) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(za); - a = BYTE_Z_LVAL_PP(za); - } else { - WRONG_PARAM_COUNT; + if (!filter) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFilter"); } - - convert_to_double_ex(ratio); - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - - SWFGradient_addEntry( getGradient(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(ratio), BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), a - ); + return (SWFFilter)filter; } /* }}} */ -static zend_function_entry swfgradient_functions[] = { - PHP_ME(swfgradient, __construct, NULL, 0) - PHP_ME(swfgradient, addEntry, NULL, 0) +static void destroy_SWFFilter_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFFilter((SWFFilter)resource->ptr); +} + +static zend_function_entry swffilter_functions[] = { + PHP_ME(swffilter, __construct, NULL, 0) { NULL, NULL, NULL } }; - /* }}} */ /* {{{ SWFMorph @@ -1735,7 +3128,7 @@ static SWFMorph getMorph(zval *id TSRMLS void *morph = SWFgetProperty(id, "morph", 5, le_swfmorphp TSRMLS_CC); if (!morph) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFMorph"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMorph"); } return (SWFMorph)morph; } @@ -1778,6 +3171,107 @@ static zend_function_entry swfmorph_func /* }}} */ +/* {{{ SWFSoundStream + */ + +/* {{{ proto class soundstream::init(file) */ +PHP_METHOD(swfsoundstream, __construct) +{ + zval *zfile; + SWFSoundStream sound = NULL; + SWFInput input = NULL; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zfile) == FAILURE) { + return; + } + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening sound file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "soundstream::init: need either a filename, " + "a file ressource or SWFInput buffer."); + } + + sound = newSWFSoundStream_fromInput(input); + + if(sound) { + ret = zend_list_insert(sound, le_swfsoundstreamp); + object_init_ex(getThis(), soundstream_class_entry_ptr); + add_property_resource(getThis(), "soundstream", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +/* {{{ internal function getSoundStream + Returns the SWFSoundStream object contained in zval *id */ +static SWFSoundStream getSoundStream(zval *id TSRMLS_DC) +{ + void *sound = SWFgetProperty(id, "soundstream", strlen("soundstream"), + le_swfsoundstreamp TSRMLS_CC); + if(!sound) + php_error(E_ERROR, "called object is not an SWFSoundStream!"); + return (SWFSoundStream)sound; +} +/* }}} */ + +/* {{{ internal function destroy_SWFSoundStream */ +static void destroy_SWFSoundStream_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFSoundStream((SWFSoundStream)resource->ptr); +} +/* }}} */ + +/* {{{ + returns the duration of the sound stream */ +PHP_METHOD(swfsoundstream, getDuration) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(SWFSoundStream_getDuration(getSoundStream(getThis() TSRMLS_CC))); +} +/* }}} */ + +/* {{{ set initial mp3 delay seek */ +PHP_METHOD(swfsoundstream, setInitialMp3Delay) +{ + long delay; + SWFSoundStream stream = getSoundStream(getThis() TSRMLS_CC); + + if ( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &delay) == FAILURE ) + { + return; + } + + SWFSoundStream_setInitialMp3Delay(stream, delay); +} +/* }}} */ + + +static zend_function_entry swfsoundstream_functions[] = { + PHP_ME(swfsoundstream, __construct, NULL, 0) + PHP_ME(swfsoundstream, getDuration, NULL, 0) + PHP_ME(swfsoundstream, setInitialMp3Delay, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ + /* {{{ SWFSound */ /* {{{ internal function SWFSound getSound(zval *id) Returns the Sound object in zval *id */ @@ -1787,59 +3281,66 @@ SWFSound getSound(zval *id TSRMLS_DC) void *sound = SWFgetProperty(id, "sound", 5, le_swfsoundp TSRMLS_CC); if(!sound) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFSound!"); + php_error(E_ERROR, "called object is not an SWFSound!"); return (SWFSound)sound; } /* }}} */ -/* {{{ proto void swfsound::__construct(string filename, int flags) - Creates a new SWFSound object from given file */ +/* {{{ proto void swfsound::__construct(string filename/SWFInput/SWFSoundstream[, int flags]) + Creates a new SWFSound object from given file + Takes either a Filename or SWFInput memory buffer AND flags or + a SWFSoundStream object with NO flags. +*/ PHP_METHOD(swfsound, __construct) { - zval **zfile, **zflags; - SWFSound sound; - SWFInput input; - int flags; + zval *zfile; + long flags; + SWFSound sound = NULL; + SWFInput input = NULL; + SWFSoundStream stream; int ret; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &zfile, &flags) == FAILURE) { + return; + } + if(ZEND_NUM_ARGS() == 1) { - if(zend_get_parameters_ex(1, &zfile) == FAILURE) - WRONG_PARAM_COUNT; - flags = 0; + stream = getSoundStream(zfile TSRMLS_CC); + sound = newSWFSound_fromSoundStream(stream); } else if(ZEND_NUM_ARGS() == 2) { - if(zend_get_parameters_ex(2, &zfile, &zflags) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_long_ex(zflags); - flags = Z_LVAL_PP(zflags); - } - else - WRONG_PARAM_COUNT; + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening sound file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; - if(Z_TYPE_PP(zfile) != IS_RESOURCE) - { - convert_to_string_ex(zfile); - PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile)); - input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); - zend_list_addref(zend_list_insert(input, le_swfinputp)); + default: + php_error(E_ERROR, "swfsound::__construct: need either a filename, " + "a file ressource or SWFInput buffer."); + } + sound = newSWFSound_fromInput(input, flags); } - else - input = getInput(zfile TSRMLS_CC); - -#ifdef HAVE_NEW_MING - sound = newSWFSound_fromInput(input, flags); -#else - sound = newSWFSound_fromInput(input); -#endif - ret = zend_list_insert(sound, le_swfsoundp); - - object_init_ex(getThis(), sound_class_entry_ptr); - add_property_resource(getThis(), "sound", ret); - zend_list_addref(ret); + if(sound != NULL) + { + ret = zend_list_insert(sound, le_swfsoundp); + object_init_ex(getThis(), sound_class_entry_ptr); + add_property_resource(getThis(), "sound", ret); + zend_list_addref(ret); + } } static void destroy_SWFSound_resource(zend_rsrc_list_entry *resource TSRMLS_DC) @@ -1856,7 +3357,6 @@ static zend_function_entry swfsound_func /* }}} */ -/* {{{ SWFSoundInstance */ #ifdef HAVE_NEW_MING /* should handle envelope functions */ /* {{{ internal function SWFSoundInstance getSoundInstance(zval *id) @@ -1867,7 +3367,7 @@ SWFSoundInstance getSoundInstance(zval * void *inst = SWFgetProperty(id, "soundinstance", 13, le_swfsoundinstancep TSRMLS_CC); if (!inst) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFSoundInstance!"); + php_error(E_ERROR, "called object is not an SWFSoundInstance!"); return (SWFSoundInstance)inst; } @@ -1890,31 +3390,32 @@ PHP_METHOD(swfsoundinstance, noMultiple) PHP_METHOD(swfsoundinstance, loopInPoint) { - zval **zpoint; - SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); + long point; - if((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &zpoint) == FAILURE) - WRONG_PARAM_COUNT; + SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); - convert_to_long_ex(zpoint); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &point) == FAILURE) { + return; + } - SWFSoundInstance_setLoopInPoint(inst, Z_LVAL_PP(zpoint)); + SWFSoundInstance_setLoopInPoint(inst, point); } /* }}} */ + /* {{{ swfsoundinstance_loopoutpoint(point) */ PHP_METHOD(swfsoundinstance, loopOutPoint) { - zval **zpoint; - SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); + long point; - if((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &zpoint) == FAILURE) - WRONG_PARAM_COUNT; + SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); - convert_to_long_ex(zpoint); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &point) == FAILURE) { + return; + } - SWFSoundInstance_setLoopOutPoint(inst, Z_LVAL_PP(zpoint)); + SWFSoundInstance_setLoopOutPoint(inst, point); } /* }}} */ @@ -1922,15 +3423,14 @@ PHP_METHOD(swfsoundinstance, loopOutPoin PHP_METHOD(swfsoundinstance, loopCount) { - zval **zcount; + long count; SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); - if((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &zcount) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_long_ex(zcount); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &count) == FAILURE) { + return; + } - SWFSoundInstance_setLoopCount(inst, Z_LVAL_PP(zcount)); + SWFSoundInstance_setLoopCount(inst, count); } /* }}} */ @@ -1944,38 +3444,48 @@ static zend_function_entry swfsoundinsta /* {{{ SWFVideoStream */ -/* {{{ proto class swfvideostream_init([file]) +/* {{{ proto class swfvideostream_init([filename]) Returns a SWVideoStream object */ - PHP_METHOD(swfvideostream, __construct) { - zval **zfile = NULL; + zval *zfile = NULL; SWFVideoStream stream; - SWFInput input; + SWFInput input = NULL; int ret; - switch(ZEND_NUM_ARGS()) { - case 1: - if(zend_get_parameters_ex(1, &zfile) == FAILURE) - WRONG_PARAM_COUNT; - - if(Z_TYPE_PP(zfile) != IS_RESOURCE) - { - convert_to_string_ex(zfile); - input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); - zend_list_addref(zend_list_insert(input, le_swfinputp)); - } - else - input = getInput(zfile TSRMLS_CC); - - stream = newSWFVideoStream_fromInput(input); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &zfile) == FAILURE) { + return; + } + switch(ZEND_NUM_ARGS()) + { + case 1: + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); break; - case 0: - stream = newSWFVideoStream(); + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening sound video failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); break; + default: - WRONG_PARAM_COUNT; - break; + php_error(E_ERROR, "swfvideostream_init: need either a filename, " + "a file ressource or SWFInput buffer."); + } + stream = newSWFVideoStream_fromInput(input); + break; + case 0: + stream = newSWFVideoStream(); + break; + default: /* warn */ + return; } if(stream) { @@ -1984,7 +3494,6 @@ PHP_METHOD(swfvideostream, __construct) add_property_resource(getThis(), "videostream", ret); zend_list_addref(ret); } - } static void destroy_SWFVideoStream_resource(zend_rsrc_list_entry *resource TSRMLS_DC) @@ -1995,14 +3504,11 @@ static void destroy_SWFVideoStream_resou /* {{{ internal function getVideoStream Returns the SWFVideoStream object contained in zval *id */ - static SWFVideoStream getVideoStream(zval *id TSRMLS_DC) { void *stream = SWFgetProperty(id, "videostream", 11, le_swfvideostreamp TSRMLS_CC); - if(!stream) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFVideoStream!"); - + php_error(E_ERROR, "called object is not an SWFVideoStream!"); return (SWFVideoStream)stream; } @@ -2010,82 +3516,196 @@ static SWFVideoStream getVideoStream(zva /* {{{ setDimension */ -PHP_METHOD(swfvideostream, setdimension) +PHP_METHOD(swfvideostream, setdimension) +{ + long x, y; + SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC); + if(!stream) + php_error(E_ERROR, "getVideoStream returned NULL"); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &x, &y) == FAILURE) { + return; + } + + SWFVideoStream_setDimension(stream, x, y); +} +/* }}} */ + +/* {{{ getNumFrames */ +PHP_METHOD(swfvideostream, getnumframes) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(SWFVideoStream_getNumFrames(getVideoStream(getThis() TSRMLS_CC))); +} +/* }}} */ + +/* {{{ hasAudio */ +PHP_METHOD(swfvideostream, hasaudio) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(SWFVideoStream_hasAudio(getVideoStream(getThis() TSRMLS_CC))); +} +/* }}} */ + +#if HAVE_SWFVIDEOSTREAM_NEXTFRAME +/* {{{ proto swfvideostream::nextFrame */ +PHP_METHOD(swfvideostream, nextFrame) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(SWFVideoStream_nextFrame(getVideoStream(getThis() TSRMLS_CC))); +} +/* }}} */ +#endif + +#if HAVE_SWFVIDEOSTREAM_SETFRAMEMODE +/* {{{ proto swfvideostream::setFrameMode */ +PHP_METHOD(swfvideostream, setFrameMode) { - zval **x, **y; + long mode; SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC); if(!stream) - php_error(E_RECOVERABLE_ERROR, "getVideoSTream returned NULL"); - - if( ZEND_NUM_ARGS() != 2 - || zend_get_parameters_ex(2, &x, &y) == FAILURE ) - WRONG_PARAM_COUNT; + php_error(E_ERROR, "getVideoStream returned NULL"); - convert_to_long_ex(x); - convert_to_long_ex(y); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { + return; + } - SWFVideoStream_setDimension(stream, Z_LVAL_PP(x), Z_LVAL_PP(y)); + RETURN_LONG(SWFVideoStream_setFrameMode(stream, mode)); } /* }}} */ +#endif -/* {{{ getNumFrames */ -PHP_METHOD(swfvideostream, getnumframes) +#if HAVE_SWFVIDEOSTREAM_SEEK +/* {{{ proto swfvideostream::seek(frame, whence) */ +PHP_METHOD(swfvideostream, seek) { - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + long frame, whence; + SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC); + if(!stream) + php_error(E_ERROR, "getVideoStream returned NULL"); - RETURN_LONG(SWFVideoStream_getNumFrames(getVideoStream(getThis() TSRMLS_CC))); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &frame, &whence) == FAILURE) { + return; + } + + RETURN_LONG(SWFVideoStream_seek(stream, frame, whence)); } /* }}} */ - - +#endif + static zend_function_entry swfvideostream_functions[] = { PHP_ME(swfvideostream, __construct, NULL, 0) PHP_ME(swfvideostream, setdimension, NULL, 0) PHP_ME(swfvideostream, getnumframes, NULL, 0) + PHP_ME(swfvideostream, hasaudio, NULL, 0) +#if HAVE_SWFVIDEOSTREAM_SETFRAMEMODE + PHP_ME(swfvideostream, setFrameMode, NULL, 0) +#endif +#if HAVE_SWFVIDEOSTREAM_NEXTFRAME + PHP_ME(swfvideostream, nextFrame, NULL, 0) +#endif +#if HAVE_SWFVIDEOSTREAM_SEEK + PHP_ME(swfvideostream, seek, NULL, 0) +#endif { NULL, NULL, NULL } }; /* }}} */ -#endif -#ifdef HAVE_SWFPREBUILTCLIP +/* {{{ SWFBinaryData + */ + +/* {{{ proto class swfbinarydata_init(string) + Returns a SWFBinaryData object */ +PHP_METHOD(swfbinarydata, __construct) +{ + char *data; + int data_len; + SWFBinaryData bd = NULL; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { + return; + } + bd = newSWFBinaryData((unsigned char *)data, data_len); + + if(bd) { + ret = zend_list_insert(bd, le_swfbinarydatap); + object_init_ex(getThis(), binarydata_class_entry_ptr); + add_property_resource(getThis(), "binarydata", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +/* {{{ internal function getBinaryData + Returns the SWFBinaryData object contained in zval *id */ +static inline SWFBinaryData getBinaryData(zval *id TSRMLS_DC) +{ + void *bd = SWFgetProperty(id, "binarydata", strlen("binarydata"), le_swfbinarydatap TSRMLS_CC); + if(!bd) + php_error(E_ERROR, "called object is not an SWFBinaryData!"); + return (SWFBinaryData)bd; +} +/* }}} */ + +/* {{{ internal function destroy_SWFBinaryData */ +static void destroy_SWFBinaryData_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFBinaryData((SWFBinaryData)resource->ptr); +} +/* }}} */ + +static zend_function_entry swfbinarydata_functions[] = { + PHP_ME(swfbinarydata, __construct, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ + /* {{{ SWFPrebuiltClip */ -/* {{{ proto class swfprebuiltclip_init([file]) +/* {{{ proto class swfprebuiltclip_init(filename / SWFInput ) Returns a SWFPrebuiltClip object */ - PHP_METHOD(swfprebuiltclip, __construct) { - zval **zfile = NULL; + zval *zfile = NULL; SWFPrebuiltClip clip; - SWFInput input; + SWFInput input = NULL; int ret; - switch(ZEND_NUM_ARGS()) { - case 1: - if(zend_get_parameters_ex(1, &zfile) == FAILURE) - WRONG_PARAM_COUNT; - - if(Z_TYPE_PP(zfile) != IS_RESOURCE) - { - convert_to_string_ex(zfile); - input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); - zend_list_addref(zend_list_insert(input, le_swfinputp)); - } - else - input = getInput(zfile TSRMLS_CC); - - clip = newSWFPrebuiltClip_fromInput(input); - break; -/* not sure whether this makes sense - there would have to be a function to add contents - case 0: - clip = newSWFPrebuiltClip(); - break; */ - default: - WRONG_PARAM_COUNT; - break; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zfile) == FAILURE) { + return; + } + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening prebuilt clip file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "swfprebuiltclip_init: need either a filename, " + "a file ressource or SWFInput buffer."); } + + clip = newSWFPrebuiltClip_fromInput(input); if(clip) { ret = zend_list_insert(clip, le_swfprebuiltclipp); @@ -2105,18 +3725,15 @@ static void destroy_SWFPrebuiltClip_reso /* {{{ internal function getPrebuiltClip Returns the SWFPrebuiltClip object contained in zval *id */ - static SWFPrebuiltClip getPrebuiltClip(zval *id TSRMLS_DC) { void *clip = SWFgetProperty(id, "prebuiltclip", 12, le_swfprebuiltclipp TSRMLS_CC); - if(!clip) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFPrebuiltClip!"); - + php_error(E_ERROR, "called object is not an SWFPrebuiltClip!"); return (SWFPrebuiltClip)clip; } - /* }}} */ + static zend_function_entry swfprebuiltclip_functions[] = { PHP_ME(swfprebuiltclip, __construct, NULL, 0) { NULL, NULL, NULL } @@ -2125,24 +3742,21 @@ static zend_function_entry swfprebuiltcl /* }}} */ #endif -/* }}} */ - /* {{{ SWFMovie */ /* {{{ proto void swfmovie::__construct(int version) Creates swfmovie object according to the passed version */ PHP_METHOD(swfmovie, __construct) { - zval **version; + long version; SWFMovie movie; int ret; if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &version) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &version) == FAILURE) { + return; } - convert_to_long_ex(version); - movie = newSWFMovieWithVersion(Z_LVAL_PP(version)); + movie = newSWFMovieWithVersion(version); } else { movie = newSWFMovie(); /* default version 4 */ } @@ -2167,7 +3781,7 @@ static SWFMovie getMovie(zval *id TSRMLS void *movie = SWFgetProperty(id, "movie", 5, le_swfmoviep TSRMLS_CC); if (!movie) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFMovie"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMovie"); } return (SWFMovie)movie; } @@ -2185,85 +3799,78 @@ PHP_METHOD(swfmovie, nextFrame) Labels frame */ PHP_METHOD(swfmovie, labelFrame) { - zval **label; + char *label; + int label_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &label) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &label, &label_len) == FAILURE) { + return; } - convert_to_string_ex(label); - SWFMovie_labelFrame(getMovie(getThis() TSRMLS_CC), Z_STRVAL_PP(label)); + + SWFMovie_labelFrame(getMovie(getThis() TSRMLS_CC), label); } /* }}} */ -#ifdef HAVE_SWFMOVIE_NAMEDANCHOR -/* {{{ proto void swfmovie::namedanchor(string name) +/* {{{ proto void swfmovie::namedanchor() */ PHP_METHOD(swfmovie, namedAnchor) { - zval **name; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &name) == FAILURE) { - WRONG_PARAM_COUNT; + char *label; + int label_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &label, &label_len) == FAILURE) { + return; } - - convert_to_string_ex(name); - - SWFMovie_namedAnchor(getMovie(getThis() TSRMLS_CC), Z_STRVAL_PP(name)); + + SWFMovie_namedAnchor(getMovie(getThis() TSRMLS_CC), label); } /* }}} */ -#endif /* {{{ proto void swfmovie::protect([ string pasword]) */ PHP_METHOD(swfmovie, protect) { - zval **zchar; + char *passwd = NULL; + int passwd_len; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - - switch(ZEND_NUM_ARGS() ) { - case 0: - SWFMovie_protect(movie, NULL); - break; - case 1: - if( zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(zchar); - SWFMovie_protect(movie,Z_STRVAL_PP(zchar)); - break; - default: - WRONG_PARAM_COUNT; - break; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &passwd, &passwd_len) == FAILURE) { + return; } + SWFMovie_protect(movie, passwd); } /* }}} */ - /* {{{ proto object swfmovie::add(object SWFBlock) */ PHP_METHOD(swfmovie, add) { - zval **zchar; + zval *zchar; int ret; SWFBlock block; SWFDisplayItem item; SWFMovie movie = getMovie(getThis() TSRMLS_CC); + SWFMovieBlockType ublock; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; } - - convert_to_object_ex(zchar); /* XXX - SWFMovie_add deals w/ all block types. Probably will need to add that.. */ - if (Z_OBJCE_PP(zchar) == action_class_entry_ptr) { - block = (SWFBlock) getAction(*zchar TSRMLS_CC); - } else { - block = (SWFBlock) getCharacter(*zchar TSRMLS_CC); + if (Z_OBJCE_P(zchar) == action_class_entry_ptr) { + block = (SWFBlock) getAction(zchar TSRMLS_CC); + } + else if (Z_OBJCE_P(zchar) == initaction_class_entry_ptr) { + block = (SWFBlock) getInitAction(zchar TSRMLS_CC); + } + else if(Z_OBJCE_P(zchar) == character_class_entry_ptr) { + block = (SWFBlock) getCharacterClass(zchar TSRMLS_CC); + } + else { + block = (SWFBlock) getCharacter(zchar TSRMLS_CC); } - item = SWFMovie_add(movie, block); - + ublock.block = block; + item = SWFMovie_add_internal(movie, ublock); if (item != NULL) { /* try and create a displayitem object */ ret = zend_list_insert(item, le_swfdisplayitemp); @@ -2278,15 +3885,14 @@ PHP_METHOD(swfmovie, add) */ PHP_METHOD(swfmovie, remove) { - zval **zchar; + zval *zchar; SWFDisplayItem item; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; } - convert_to_object_ex(zchar); - item = getDisplayItem(*zchar TSRMLS_CC); + item = getDisplayItem(zchar TSRMLS_CC); SWFMovie_remove(movie, item); } /* }}} */ @@ -2303,45 +3909,28 @@ static void phpByteOutputMethod(byte b, PHP_METHOD(swfmovie, output) { SWFMovie movie = getMovie(getThis() TSRMLS_CC); -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) - zval **zlimit = NULL; - int limit = -1; - int argc = ZEND_NUM_ARGS(); +#if !defined(HAVE_NEW_MING) + long limit = -1; int oldval = INT_MIN; long out; - if(argc) { - if (zend_get_parameters_ex(1, &zlimit) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_long_ex(zlimit); - limit = Z_LVAL_PP(zlimit); - - if ((limit < 0) || (limit > 9)) { - php_error(E_WARNING,"compression level must be within 0..9"); - RETURN_FALSE; - } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &limit) == FAILURE) { + return; } oldval = Ming_setSWFCompression(limit); out = SWFMovie_output(movie, &phpByteOutputMethod, NULL); - if (oldval >= -1 && oldval <= 9) { - Ming_setSWFCompression(oldval); - } + Ming_setSWFCompression(oldval); + RETURN_LONG(out); #elif defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL) - zval **zlimit = NULL; - int limit = -1; + long limit = -1; int argc = ZEND_NUM_ARGS(); if(argc) { - if (zend_get_parameters_ex(1, &zlimit) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &limit) == FAILURE) { + return; } - convert_to_long_ex(zlimit); - limit = Z_LVAL_PP(zlimit); - if ((limit < 0) || (limit > 9)) { php_error(E_WARNING,"compression level must be within 0..9"); RETURN_FALSE; @@ -2370,53 +3959,38 @@ static void phpStreamOutputMethod(byte b */ PHP_METHOD(swfmovie, saveToFile) { - zval **x; -#if defined(HAVE_MING_ZLIB) || defined(HAVE_NEW_MING) - zval **zlimit = NULL; - int limit = -1; -#endif -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + zval *x; + long limit = -1; +#if !defined(HAVE_NEW_MING) int oldval = INT_MIN; - long out; #endif + long out; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); php_stream *what; - switch (ZEND_NUM_ARGS()) { - case 1: - if (zend_get_parameters_ex(1, &x) == FAILURE) - WRONG_PARAM_COUNT; - break; - case 2: -#if defined(HAVE_MING_ZLIB) || defined(HAVE_NEW_MING) - if (zend_get_parameters_ex(2, &x, &zlimit) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_long_ex(zlimit); - limit = Z_LVAL_PP(zlimit); - if ((limit < 0) || (limit > 9)) { - php_error(E_WARNING,"compression level must be within 0..9"); - RETURN_FALSE; - } -#endif -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &x, &limit) == FAILURE) { + return; + } + + if ((limit < 0) || (limit > 9)) { + php_error(E_WARNING,"compression level must be within 0..9"); + RETURN_FALSE; + } +#if !defined(HAVE_NEW_MING) oldval = Ming_setSWFCompression(limit); #endif - break; - default: - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(what, php_stream *, x, -1,"File-Handle",php_file_le_stream()); -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + ZEND_FETCH_RESOURCE(what, php_stream *, &x, -1,"File-Handle",php_file_le_stream()); +#if !defined(HAVE_NEW_MING) out = SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, what); - if (oldval >= -1 && oldval <=9) - Ming_setSWFCompression(oldval); - RETURN_LONG(out); + Ming_setSWFCompression(oldval); #elif defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL) - RETURN_LONG(SWFMovie_output(movie, &phpStreamOutputMethod, what, limit)); + out = SWFMovie_output(movie, &phpStreamOutputMethod, what, limit); #else - RETURN_LONG(SWFMovie_output(movie, &phpStreamOutputMethod, what)); + out = SWFMovie_output(movie, &phpStreamOutputMethod, what); #endif + RETURN_LONG(out); } /* }}} */ @@ -2424,59 +3998,37 @@ PHP_METHOD(swfmovie, saveToFile) Saves the movie. 'where' can be stream and the movie will be saved there otherwise it is treated as string and written in file with that name */ PHP_METHOD(swfmovie, save) { - zval **x; -#if defined(HAVE_MING_ZLIB) || defined(HAVE_NEW_MING) - zval **zlimit = NULL; - int limit = -1; -#endif -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + zval *x; + long limit = -1; +#if !defined(HAVE_NEW_MING) int oldval = INT_MIN; #endif long retval; php_stream *stream; - switch (ZEND_NUM_ARGS()) { - case 1: - if (zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; - } - break; - case 2: -#if defined(HAVE_MING_ZLIB) || defined(HAVE_NEW_MING) - if (zend_get_parameters_ex(2, &x, &zlimit) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(zlimit); - limit = Z_LVAL_PP(zlimit); - if ((limit < 0) || (limit > 9)) { - php_error(E_WARNING,"compression level must be within 0..9"); - RETURN_FALSE; - } -#endif -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &x, &limit) == FAILURE) { + return; + } + +#if !defined(HAVE_NEW_MING) oldval = Ming_setSWFCompression(limit); #endif - break; - default: - WRONG_PARAM_COUNT; - } - if (Z_TYPE_PP(x) == IS_RESOURCE) { - ZEND_FETCH_RESOURCE(stream, php_stream *, x, -1,"File-Handle",php_file_le_stream()); + if (Z_TYPE_P(x) == IS_RESOURCE) { + ZEND_FETCH_RESOURCE(stream, php_stream *, &x, -1,"File-Handle",php_file_le_stream()); #if defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL) RETURN_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, stream, limit)); #else RETVAL_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, stream)); -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) - if(oldval >= -1 && oldval <=9) +#if !defined(HAVE_NEW_MING) Ming_setSWFCompression(oldval); #endif return; #endif } - convert_to_string_ex(x); - stream = php_stream_open_wrapper(Z_STRVAL_PP(x), "wb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); + convert_to_string(x); + stream = php_stream_open_wrapper(Z_STRVAL_P(x), "wb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); if (stream == NULL) { RETURN_FALSE; @@ -2488,9 +4040,8 @@ PHP_METHOD(swfmovie, save) retval = SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, (void *)stream); #endif php_stream_close(stream); -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) - if(oldval >= -1 && oldval <=9) - Ming_setSWFCompression(oldval); +#if!defined(HAVE_NEW_MING) + Ming_setSWFCompression(oldval); #endif RETURN_LONG(retval); @@ -2501,17 +4052,14 @@ PHP_METHOD(swfmovie, save) Sets background color (r,g,b) */ PHP_METHOD(swfmovie, setBackground) { - zval **r, **g, **b; + long r, g, b; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &r, &g, &b) == FAILURE) { + return; } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - SWFMovie_setBackground(movie, Z_LVAL_PP(r), Z_LVAL_PP(g), Z_LVAL_PP(b)); + SWFMovie_setBackground(movie, r, g, b); } /* }}} */ @@ -2519,15 +4067,14 @@ PHP_METHOD(swfmovie, setBackground) Sets movie rate */ PHP_METHOD(swfmovie, setRate) { - zval **rate; + double rate; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &rate) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &rate) == FAILURE) { + return; } - convert_to_double_ex(rate); - SWFMovie_setRate(movie, FLOAT_Z_DVAL_PP(rate)); + SWFMovie_setRate(movie, rate); } /* }}} */ @@ -2535,16 +4082,14 @@ PHP_METHOD(swfmovie, setRate) Sets movie dimension */ PHP_METHOD(swfmovie, setDimension) { - zval **x, **y; + double x, y; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFMovie_setDimension(movie, FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + SWFMovie_setDimension(movie, x, y); } /* }}} */ @@ -2552,57 +4097,174 @@ PHP_METHOD(swfmovie, setDimension) Sets number of frames */ PHP_METHOD(swfmovie, setFrames) { - zval **frames; + long frames; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &frames) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &frames) == FAILURE) { + return; } - convert_to_long_ex(frames); - SWFMovie_setNumberOfFrames(movie, Z_LVAL_PP(frames)); + SWFMovie_setNumberOfFrames(movie, frames); } /* }}} */ #ifdef HAVE_NEW_MING -/* {{{ proto int swfmovie::streamMP3(mixed file [, float skip]) - Sets sound stream of the SWF movie. The parameter can be stream or string. Retuens the number of frames. */ +/* {{{ proto void swfmovie::addMetadata(string xml) + * */ +PHP_METHOD(swfmovie, addMetadata) +{ + char *xml; + int xml_len; + + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &xml, &xml_len) == FAILURE) { + return; + } + + SWFMovie_addMetadata(movie, xml); +} +/* }}} */ + +/* {{{ proto void swfmovie::setScriptLimits(int maxRecursion, int timeout) +*/ +PHP_METHOD(swfmovie, setScriptLimits) +{ + long maxRecursion, timeout; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &maxRecursion, &timeout) == FAILURE) { + return; + } + + SWFMovie_setScriptLimits(movie, maxRecursion, timeout); +} +/* }}} */ + +/* {{{ proto void swfmovie::setTabIndex(int depth, int index) + * */ +PHP_METHOD(swfmovie, setTabIndex) +{ + long depth, index; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &depth, &index) == FAILURE) { + return; + } + + SWFMovie_setTabIndex(movie, depth, index); +} +/* }}} */ + +/* {{{ proto void swfmovie::assignSymbol(SWFCharacter character, string name) + * */ +PHP_METHOD(swfmovie, assignSymbol) +{ + zval *zchar; + char *name; + int name_len; + SWFCharacter character; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os", &zchar, &name, &name_len) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFMovie_assignSymbol(movie, character, name); +} +/* }}} */ + +/* {{{ proto void swfmovie::defineScene(int offset, string name) + * */ +PHP_METHOD(swfmovie, defineScene) +{ + long offset; + char *name; + int name_len; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &offset, &name, &name_len) == FAILURE) { + return; + } + + SWFMovie_defineScene(movie, offset, name); +} +/* }}} */ + +/* {{{ proto void swfmovie::setNetworkAccess(int flag) + * */ +PHP_METHOD(swfmovie, setNetworkAccess) +{ + long flag; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) { + return; + } + + SWFMovie_setNetworkAccess(movie, flag); +} +/* }}} */ + +/* {{{ proto long swfmovie::streamMP3(mixed filename / SWFInput [, double skip]) + Sets sound stream of the SWF movie. The parameter can be stream or string. */ PHP_METHOD(swfmovie, streamMP3) { - zval **zfile, **zskip; - float skip; + zval *zfile; + double skip = 0; SWFSoundStream sound; - SWFInput input; + SWFInput input = NULL; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - switch (ZEND_NUM_ARGS()) { - case 1: - if(zend_get_parameters_ex(1, &zfile) == FAILURE) - WRONG_PARAM_COUNT; - skip = 0; - break; - case 2: - if(zend_get_parameters_ex(2, &zfile, &zskip) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_double_ex(zskip); - skip = Z_DVAL_PP(zskip); - break; - default: - WRONG_PARAM_COUNT; - break; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|d", &zfile, &skip) == FAILURE) { + return; } - - if (Z_TYPE_PP(zfile) != IS_RESOURCE) { - convert_to_string_ex(zfile); - input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); - zend_list_addref(zend_list_insert(input, le_swfinputp)); - } else { + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if (input == NULL) { + php_error(E_ERROR, "opening mp3 file failed"); + } + + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "swfmovie::streamMP3: need either a filename, " + "a file ressource or SWFInput buffer."); } - + sound = newSWFSoundStream_fromInput(input); SWFMovie_setSoundStreamAt(movie, sound, skip); - RETURN_LONG(SWFSoundStream_getFrames(sound)); + RETURN_LONG(SWFSoundStream_getDuration(sound) / SWFMovie_getRate(movie)); +} +/* }}} */ + +/* {{{ proto long swfmovie::setSoundStream + Sets sound stream of the SWF movie. The parameter must be a SoundStream object */ +PHP_METHOD(swfmovie, setSoundStream) +{ + zval *zstream; + double skip = 0; + SWFSoundStream sound; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|d", &zstream, &skip) == FAILURE) { + return; + } + + sound = getSoundStream(zstream TSRMLS_CC); + SWFMovie_setSoundStreamAt(movie, sound, skip); + RETURN_LONG(SWFSoundStream_getDuration(sound) / SWFMovie_getRate(movie)); } /* }}} */ @@ -2610,19 +4272,19 @@ PHP_METHOD(swfmovie, streamMP3) PHP_METHOD(swfmovie, addExport) { - zval **zchar, **zname; + zval *zchar; + char *name; + int name_len; SWFBlock block; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zchar, &zname) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_object_ex(zchar); - convert_to_string_ex(zname); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os", &zchar, &name, &name_len) == FAILURE) { + return; + } - block = (SWFBlock)getCharacter(*zchar TSRMLS_CC); + block = (SWFBlock)getCharacter(zchar TSRMLS_CC); - SWFMovie_addExport(movie, block, Z_STRVAL_PP(zname)); + SWFMovie_addExport(movie, block, name); } /* }}} */ @@ -2641,17 +4303,17 @@ PHP_METHOD(swfmovie, writeExports) PHP_METHOD(swfmovie, startSound) { - zval **zsound; + zval *zsound; int ret; SWFSound sound; SWFSoundInstance item; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) { + return; + } - convert_to_object_ex(zsound); - sound = (SWFSound)getSound(*zsound TSRMLS_CC); + sound = (SWFSound)getSound(zsound TSRMLS_CC); item = SWFMovie_startSound(movie, sound); @@ -2666,72 +4328,69 @@ PHP_METHOD(swfmovie, startSound) } /* }}} */ -/* {{{ void swfmovie_stopsound */ - +/* {{{ void swfmovie::stopsound(sound) */ PHP_METHOD(swfmovie, stopSound) { - zval **zsound; + zval *zsound; SWFSound sound; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) { + return; + } - convert_to_object_ex(zsound); - sound = (SWFSound)getSound(*zsound TSRMLS_CC); + sound = (SWFSound)getSound(zsound TSRMLS_CC); SWFMovie_stopSound(movie, sound); } /* }}} */ -/* {{{ void swfmovie_importChar */ - +/* {{{ void swfmovie::importChar(filename, importname) */ PHP_METHOD(swfmovie, importChar) { SWFMovie movie; - SWFCharacter res; + SWFCharacter character; int ret; - zval **libswf, **name; + char *libswf, *name; + int libswf_len, name_len; - if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &libswf, &name) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_string_ex(libswf); - convert_to_string_ex(name); - movie = getMovie(getThis() TSRMLS_CC); - res = SWFMovie_importCharacter(movie, Z_STRVAL_PP(libswf), Z_STRVAL_PP(name)); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &libswf, &libswf_len, &name, &name_len) == FAILURE) { + return; + } - if(res != NULL) + movie = getMovie(getThis() TSRMLS_CC); + character = SWFMovie_importCharacter(movie, libswf, name); + if(character != NULL) { - /* try and create a sprite object */ - ret = zend_list_insert(res, le_swfspritep); - object_init_ex(return_value, sprite_class_entry_ptr); - add_property_resource(return_value, "sprite", ret); + ret = zend_list_insert(character, le_swfcharacterp); + object_init_ex(return_value, character_class_entry_ptr); + add_property_resource(return_value, "character", ret); zend_list_addref(ret); - } + } } /* }}} */ /* {{{ void swfmovie_importFont */ - PHP_METHOD(swfmovie, importFont) { SWFMovie movie; SWFFontCharacter res; int ret; - zval **libswf, **name; + char *libswf, *name; + int libswf_len, name_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &libswf, &libswf_len, &name, &name_len) == FAILURE) { + return; + } - if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &libswf, &name) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_string_ex(libswf); - convert_to_string_ex(name); movie = getMovie(getThis() TSRMLS_CC); - PHP_MING_FILE_CHK(Z_STRVAL_PP(libswf)); - res = SWFMovie_importFont(movie, Z_STRVAL_PP(libswf), Z_STRVAL_PP(name)); + PHP_MING_FILE_CHK(libswf); + res = SWFMovie_importFont(movie, libswf, name); if(res != NULL) { /* try and create a fontchar object */ - ret = zend_list_insert(res, le_swffontcharp); + ret = zend_list_insert(res, le_swffontcharp); object_init_ex(return_value, fontchar_class_entry_ptr); add_property_resource(return_value, "fontcharacter", ret); zend_list_addref(ret); @@ -2746,27 +4405,55 @@ PHP_METHOD(swfmovie, addFont) SWFFontCharacter res; int ret; SWFFont font; - zval **zfont; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfont) == FAILURE) - WRONG_PARAM_COUNT; + zval *zfont; - convert_to_object_ex(zfont); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfont) == FAILURE) { + return; + } movie = getMovie(getThis() TSRMLS_CC); - font = getFont(*zfont TSRMLS_CC); + font = getFont(zfont TSRMLS_CC); res = SWFMovie_addFont(movie, font); - if(res != NULL) { /* try and create a fontchar object */ - ret = zend_list_insert(res, le_swffontcharp); + ret = zend_list_insert(res, le_swffontcharp); object_init_ex(return_value, fontchar_class_entry_ptr); add_property_resource(return_value, "fontcharacter", ret); zend_list_addref(ret); } } /* }}} */ + +/* {{{ void swfmovie_replace */ +PHP_METHOD(swfmovie, replace) +{ + SWFMovie movie; + zval *zitem, *zblock; + SWFDisplayItem item; + SWFBlock block; + SWFMovieBlockType ublock; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oo", &zitem, &zblock) == FAILURE) { + return; + } + + item = getDisplayItem(zitem TSRMLS_CC); + + block = (SWFBlock) getCharacter(zblock TSRMLS_CC); + movie = getMovie(getThis() TSRMLS_CC); + ublock.block = block; + + SWFMovie_replace_internal(movie, item, ublock); +} +/* }}} */ + +/* {{{ float swfmovie::getRate() */ +PHP_METHOD(swfmovie, getRate) +{ + RETURN_DOUBLE(SWFMovie_getRate(getMovie(getThis() TSRMLS_CC))); +} +/* }}} */ #endif static zend_function_entry swfmovie_functions[] = { @@ -2784,6 +4471,7 @@ static zend_function_entry swfmovie_func PHP_ME(swfmovie, setFrames, NULL, 0) #ifdef HAVE_NEW_MING PHP_ME(swfmovie, streamMP3, NULL, 0) + PHP_ME(swfmovie, setSoundStream, NULL, 0) PHP_ME(swfmovie, addExport, NULL, 0) PHP_ME(swfmovie, writeExports, NULL, 0) PHP_ME(swfmovie, startSound, NULL, 0) @@ -2792,9 +4480,15 @@ static zend_function_entry swfmovie_func PHP_ME(swfmovie, importFont, NULL, 0) PHP_ME(swfmovie, addFont, NULL, 0) PHP_ME(swfmovie, protect, NULL, 0) -#endif -#ifdef HAVE_SWFMOVIE_NAMEDANCHOR - PHP_ME(swfmovie, namedAnchor, NULL, 0) + PHP_ME(swfmovie, addMetadata, NULL, 0) + PHP_ME(swfmovie, setNetworkAccess, NULL, 0) + PHP_ME(swfmovie, setScriptLimits, NULL, 0) + PHP_ME(swfmovie, setTabIndex, NULL, 0) + PHP_ME(swfmovie, assignSymbol, NULL, 0) + PHP_ME(swfmovie, defineScene, NULL, 0) + PHP_ME(swfmovie, namedAnchor, NULL, 0) + PHP_ME(swfmovie, replace, NULL, 0) + PHP_ME(swfmovie, getRate, NULL, 0) #endif { NULL, NULL, NULL } }; @@ -2828,7 +4522,7 @@ static SWFShape getShape(zval *id TSRMLS void *shape = SWFgetProperty(id, "shape", 5, le_swfshapep TSRMLS_CC); if (!shape) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFShape"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFShape"); } return (SWFShape)shape; @@ -2839,38 +4533,134 @@ static SWFShape getShape(zval *id TSRMLS Sets the current line style for this SWFShape */ PHP_METHOD(swfshape, setLine) { - zval **w, **r, **g, **b, **a; + long w, r, g, b, a = 0xff; - if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &w, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll|l", &w, &r, &g, &b, &a) == FAILURE) { + return; + } + + SWFShape_setLine(getShape(getThis() TSRMLS_CC), (unsigned short)w, (byte)r, (byte)g, (byte)b, (byte)a); +} +/* }}} */ + +/* {{{ proto object swfshape::addSolidFill(int r, int g, int b, [int alpha]) + Returns a solid fill object, for use with swfshape_setleftfill and swfshape_setrightfill. */ +PHP_METHOD(swfshape, addSolidFill) +{ + SWFFill fill=NULL; + int ret; + + if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) { + /* it's a solid fill */ + long r, g, b, a = 0xff; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; + } + + fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a); + } else { + WRONG_PARAM_COUNT; + } + + if (!fill) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding fill to shape"); + } + + /* return an SWFFill object */ + ret = zend_list_insert(fill, le_swffillp); + object_init_ex(return_value, fill_class_entry_ptr); + add_property_resource(return_value, "fill", ret); + zend_list_addref(ret); +} +/* }}} */ + +/* {{{ proto object swfshape::addbitmapfill(bitmap, [flags]) + Returns a bitmap fill object, for use with swfshape_setleftfill and swfshape_setrightfill. */ +PHP_METHOD(swfshape, addBitmapFill) +{ + SWFFill fill=NULL; + int ret; + + if (ZEND_NUM_ARGS() == 1 || ZEND_NUM_ARGS() == 2) { + /* it's a gradient or bitmap */ + zval *arg1; + long flags = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o!|l", &arg1, &flags) == FAILURE) { + return; } - } else if (ZEND_NUM_ARGS() == 5) { - if (zend_get_parameters_ex(5, &w, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; + + if ( arg1 && Z_OBJCE_P(arg1) != bitmap_class_entry_ptr) { + + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Argument is not a bitmap"); } - convert_to_long_ex(a); - } else if (ZEND_NUM_ARGS() == 1) { - SWFShape_setLine(getShape(getThis() TSRMLS_CC), 0, 0, 0, 0, 0); - return; + + if (flags == 0) { + flags = SWFFILL_TILED_BITMAP; + } + fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC), + arg1 ? getBitmap(arg1 TSRMLS_CC) : 0, flags); + } else { WRONG_PARAM_COUNT; } + + if (!fill) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding bitmap fill to shape"); + } + + /* return an SWFFill object */ + ret = zend_list_insert(fill, le_swffillp); + object_init_ex(return_value, fill_class_entry_ptr); + add_property_resource(return_value, "fill", ret); + zend_list_addref(ret); +} +/* }}} */ - convert_to_long_ex(w); - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); +/* {{{ proto object swfshape::addGradientFill(gradient, [flags]) + Returns a gradient fill object, for use with swfshape_setleftfill and swfshape_setrightfill. */ +PHP_METHOD(swfshape, addGradientFill) +{ + SWFFill fill=NULL; + int ret; + + if (ZEND_NUM_ARGS() == 1 || ZEND_NUM_ARGS() == 2) { + /* it's a gradient or bitmap */ + zval *arg1; + long flags = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &arg1, &flags) == FAILURE) { + return; + } + + if (Z_OBJCE_P(arg1) == gradient_class_entry_ptr) { + if (flags == 0) { + flags = SWFFILL_LINEAR_GRADIENT; + } + fill = SWFShape_addGradientFill(getShape(getThis() TSRMLS_CC), getGradient(arg1 TSRMLS_CC), flags); + } else if (Z_OBJCE_P(arg1) == bitmap_class_entry_ptr) { + if (flags == 0) { + flags = SWFFILL_TILED_BITMAP; + } + fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC), getBitmap(arg1 TSRMLS_CC), flags); + } else { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Argument is not a bitmap nor a gradient"); + } - if (ZEND_NUM_ARGS() == 4) { - SWFShape_setLine(getShape(getThis() TSRMLS_CC), - (unsigned short)Z_LVAL_PP(w), BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff - ); } else { - SWFShape_setLine(getShape(getThis() TSRMLS_CC), - (unsigned short)Z_LVAL_PP(w), BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a) - ); + WRONG_PARAM_COUNT; + } + + if (!fill) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding fill to shape"); } + + /* return an SWFFill object */ + ret = zend_list_insert(fill, le_swffillp); + object_init_ex(return_value, fill_class_entry_ptr); + add_property_resource(return_value, "fill", ret); + zend_list_addref(ret); } /* }}} */ @@ -2883,69 +4673,42 @@ PHP_METHOD(swfshape, addFill) if (ZEND_NUM_ARGS() == 1 || ZEND_NUM_ARGS() == 2) { /* it's a gradient or bitmap */ - zval **arg1; - unsigned char flags = 0; + zval *arg1; + long flags = 0; - if (ZEND_NUM_ARGS() == 2) { - zval **arg2; - if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(arg2); - flags = (unsigned char)Z_LVAL_PP(arg2); - } else { - if (zend_get_parameters_ex(1, &arg1) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &arg1, &flags) == FAILURE) { + return; } - convert_to_object_ex(arg1); - - if (Z_OBJCE_PP(arg1) == gradient_class_entry_ptr) { + if (Z_OBJCE_P(arg1) == gradient_class_entry_ptr) { if (flags == 0) { flags = SWFFILL_LINEAR_GRADIENT; } - fill = SWFShape_addGradientFill(getShape(getThis() TSRMLS_CC), getGradient(*arg1 TSRMLS_CC), flags); - } else if (Z_OBJCE_PP(arg1) == bitmap_class_entry_ptr) { + fill = SWFShape_addGradientFill(getShape(getThis() TSRMLS_CC), getGradient(arg1 TSRMLS_CC), flags); + } else if (Z_OBJCE_P(arg1) == bitmap_class_entry_ptr) { if (flags == 0) { flags = SWFFILL_TILED_BITMAP; } - fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC), getBitmap(*arg1 TSRMLS_CC), flags); + fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC), getBitmap(arg1 TSRMLS_CC), flags); } else { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Argument is not a bitmap nor a gradient"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Argument is not a bitmap nor a gradient"); } } else if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) { /* it's a solid fill */ - zval **r, **g, **b, **za; - byte a = 0xff; + long r, g, b, a = 0xff; - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &za) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(za); - a = BYTE_Z_LVAL_PP(za); - } else { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), a - ); + + fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a); } else { WRONG_PARAM_COUNT; } if (!fill) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Error adding fill to shape"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding fill to shape"); } /* return an SWFFill object */ @@ -2960,47 +4723,21 @@ PHP_METHOD(swfshape, addFill) Sets the left side fill style to fill in case only one parameter is passed. When 3 or 4 parameters are passed they are treated as : int r, int g, int b, int a . Solid fill is performed in this case before setting left side fill type. */ PHP_METHOD(swfshape, setLeftFill) { - zval **zfill, **r, **g, **b, **a; + zval *zfill; + long r, g, b, a = 0xff; SWFFill fill; - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff - ); - - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - convert_to_long_ex(a); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a) - ); - - } else if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &zfill) == FAILURE) { - WRONG_PARAM_COUNT; + if (ZEND_NUM_ARGS() == 1) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfill) == FAILURE) { + return; } - - if (Z_LVAL_PP(zfill) != 0) { - convert_to_object_ex(zfill); - fill = getFill(*zfill TSRMLS_CC); - } else { - fill = NULL; + fill = getFill(zfill TSRMLS_CC); + } + else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - } else { - WRONG_PARAM_COUNT; + fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a); } SWFShape_setLeftFill(getShape(getThis() TSRMLS_CC), fill); @@ -3011,188 +4748,129 @@ PHP_METHOD(swfshape, setLeftFill) Sets the right side fill style to fill in case only one parameter is passed. When 3 or 4 parameters are passed they are treated as : int r, int g, int b, int a . Solid fill is performed in this case before setting right side fill type. */ PHP_METHOD(swfshape, setRightFill) { - zval **zfill, **r, **g, **b, **a; + zval *zfill; + long r, g, b, a = 0xff; SWFFill fill; - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff - ); - - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - convert_to_long_ex(a); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a) - ); - } else if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &zfill) == FAILURE) { - WRONG_PARAM_COUNT; + if (ZEND_NUM_ARGS() == 1) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfill) == FAILURE) { + return; } - - if (Z_LVAL_PP(zfill) != 0) { - convert_to_object_ex(zfill); - fill = getFill(*zfill TSRMLS_CC); - } else { - fill = NULL; + fill = getFill(zfill TSRMLS_CC); + } + else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - } else { - WRONG_PARAM_COUNT; + fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a); } SWFShape_setRightFill(getShape(getThis() TSRMLS_CC), fill); } /* }}} */ -/* {{{ proto void swfshape::movepento(float x, float y) +/* {{{ proto void swfshape::movepento(double x, double y) Moves the pen to shape coordinates (x, y) */ PHP_METHOD(swfshape, movePenTo) { - zval **x, **y; + double x, y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFShape_movePenTo(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFShape_movePenTo(getShape(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfshape::movepen(float x, float y) +/* {{{ proto void swfshape::movepen(double x, double y) Moves the pen from its current location by vector (x, y) */ PHP_METHOD(swfshape, movePen) { - zval **x, **y; + double x, y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFShape_movePen(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFShape_movePen(getShape(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfshape::drawlineto(float x, float y) +/* {{{ proto void swfshape::drawlineto(double x, double y) Draws a line from the current pen position to shape coordinates (x, y) in the current line style */ PHP_METHOD(swfshape, drawLineTo) { - zval **x, **y; + double x, y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFShape_drawLineTo(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFShape_drawLineTo(getShape(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfshape::drawline(float dx, float dy) +/* {{{ proto void swfshape::drawline(double dx, double dy) Draws a line from the current pen position (x, y) to the point (x+dx, y+dy) in the current line style */ PHP_METHOD(swfshape, drawLine) { - zval **x, **y; + double x, y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFShape_drawLine(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFShape_drawLine(getShape(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfshape::drawcurveto(float ax, float ay, float bx, float by [, float dx, float dy]) +/* {{{ proto void swfshape::drawcurveto(double ax, double ay, double bx, double by [, double dx, double dy]) Draws a curve from the current pen position (x,y) to the point (bx, by) in the current line style, using point (ax, ay) as a control point. Or draws a cubic bezier to point (dx, dy) with control points (ax, ay) and (bx, by) */ PHP_METHOD(swfshape, drawCurveTo) { if (ZEND_NUM_ARGS() == 4) { - zval **cx, **cy, **ax, **ay; + double cx, cy, ax, ay; - if (zend_get_parameters_ex(4, &cx, &cy, &ax, &ay) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &cx, &cy, &ax, &ay) == FAILURE) { + return; } - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(ax); - convert_to_double_ex(ay); - - SWFShape_drawCurveTo(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(ax), FLOAT_Z_DVAL_PP(ay) - ); - + + SWFShape_drawCurveTo(getShape(getThis() TSRMLS_CC), cx, cy, ax, ay); } else if (ZEND_NUM_ARGS() == 6) { - zval **bx, **by, **cx, **cy, **dx, **dy; + double bx, by, cx, cy, dx, dy; - if (zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + return; } - convert_to_double_ex(bx); - convert_to_double_ex(by); - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(dx); - convert_to_double_ex(dy); - - RETURN_LONG(SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy)) - ); + + RETURN_LONG(SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy)); } else { WRONG_PARAM_COUNT; } } /* }}} */ -/* {{{ proto void swfshape::drawcurve(float adx, float ady, float bdx, float bdy [, float cdx, float cdy]) +/* {{{ proto void swfshape::drawcurve(double adx, double ady, double bdx, double bdy [, double cdx, double cdy]) Draws a curve from the current pen position (x, y) to the point (x+bdx, y+bdy) in the current line style, using point (x+adx, y+ady) as a control point or draws a cubic bezier to point (x+cdx, x+cdy) with control points (x+adx, y+ady) and (x+bdx, y+bdy) */ PHP_METHOD(swfshape, drawCurve) { if (ZEND_NUM_ARGS() == 4) { - zval **cx, **cy, **ax, **ay; + double cx, cy, ax, ay; - if (zend_get_parameters_ex(4, &cx, &cy, &ax, &ay) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &cx, &cy, &ax, &ay) == FAILURE) { + return; } - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(ax); - convert_to_double_ex(ay); - - SWFShape_drawCurve(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(ax), FLOAT_Z_DVAL_PP(ay) - ); + SWFShape_drawCurve(getShape(getThis() TSRMLS_CC), cx, cy, ax, ay); } else if (ZEND_NUM_ARGS() == 6) { - zval **bx, **by, **cx, **cy, **dx, **dy; + double bx, by, cx, cy, dx, dy; - if (zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + return; } - convert_to_double_ex(bx); - convert_to_double_ex(by); - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(dx); - convert_to_double_ex(dy); - - RETURN_LONG( SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy)) - ); + + RETURN_LONG(SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy)); } else { WRONG_PARAM_COUNT; } @@ -3203,100 +4881,282 @@ PHP_METHOD(swfshape, drawCurve) Draws the first character in the given string into the shape using the glyph definition from the given font */ PHP_METHOD(swfshape, drawGlyph) { - zval **font, **c, **zsize; - int size=0; - - if (ZEND_NUM_ARGS() == 2) { - if (zend_get_parameters_ex(2, &font, &c) == FAILURE) { - WRONG_PARAM_COUNT; - } - size = (int)(1024.0f/Ming_getScale()); + zval *font; + char *c; + int c_len; + long size = (long)(1024.0f/Ming_getScale()); - } else if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &font, &c, &zsize) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(zsize); - size = Z_LVAL_PP(zsize); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os|l", &font, &c, &c_len, &size) == FAILURE) { + return; } - convert_to_string_ex(c); - SWFShape_drawSizedGlyph(getShape(getThis() TSRMLS_CC), getFont(*font TSRMLS_CC), Z_STRVAL_PP(c)[0], size); + SWFShape_drawSizedGlyph(getShape(getThis() TSRMLS_CC), getFont(font TSRMLS_CC), c[0], size); } /* }}} */ -/* {{{ proto void swfshape::drawcircle(float r) +/* {{{ proto void swfshape::drawcircle(double r) Draws a circle of radius r centered at the current location, in a counter-clockwise fashion */ PHP_METHOD(swfshape, drawCircle) { - zval **r; + double r; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &r) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &r) == FAILURE) { + return; } - convert_to_double_ex(r); - SWFShape_drawCircle(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(r)); + + SWFShape_drawCircle(getShape(getThis() TSRMLS_CC), r); } /* }}} */ -/* {{{ proto void swfshape::drawarc(float r, float startAngle, float endAngle) +/* {{{ proto void swfshape::drawarc(double r, double startAngle, double endAngle) Draws an arc of radius r centered at the current location, from angle startAngle to angle endAngle measured clockwise from 12 o'clock */ PHP_METHOD(swfshape, drawArc) { - zval **r, **start, **end; + double r, start, end; - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &r, &start, &end) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &r, &start, &end) == FAILURE) { + return; } - convert_to_double_ex(r); - convert_to_double_ex(start); - convert_to_double_ex(end); /* convert angles to radians, since that's what php uses elsewhere */ - SWFShape_drawArc(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(r), FLOAT_Z_DVAL_PP(start), FLOAT_Z_DVAL_PP(end)); + SWFShape_drawArc(getShape(getThis() TSRMLS_CC), r, start, end); } /* }}} */ -/* {{{ proto void swfshape::drawcubic(float bx, float by, float cx, float cy, float dx, float dy) +/* {{{ proto void swfshape::drawcubic(double bx, double by, double cx, double cy, double dx, double dy) Draws a cubic bezier curve using the current position and the three given points as control points */ PHP_METHOD(swfshape, drawCubic) { - zval **bx, **by, **cx, **cy, **dx, **dy; + double bx, by, cx, cy, dx, dy; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + return; + } + + RETURN_LONG(SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy)); +} +/* }}} */ + +/* {{{ proto void swfshape::drawcubic(double bx, double by, double cx, double cy, double dx, double dy) + Draws a cubic bezier curve using the current position and the three given points as control points */ +PHP_METHOD(swfshape, drawCubicTo) +{ + double bx, by, cx, cy, dx, dy; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + return; + } + + RETURN_LONG(SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy)); +} +/* }}} */ + +/* {{{ proto void swfshape::end() */ +PHP_METHOD(swfshape, end) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFShape_end(getShape(getThis() TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto void swfshape::useVersion() + * SWF_SHAPE3 + * SWF_SHAPE4 + */ +PHP_METHOD(swfshape, useVersion) +{ + long ver; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ver) == FAILURE) { + return; + } + + SWFShape_useVersion(getShape(getThis() TSRMLS_CC), ver); +} +/* }}} */ + +/* {{{ proto int swfshape::getVersion() */ +PHP_METHOD(swfshape, getVersion) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(SWFShape_getVersion(getShape(getThis() TSRMLS_CC))); +} +/* }}} */ + +/* {{{ proto void swfshape::setRenderHintingFlags(flags) + * SWF_SHAPE_USESCALINGSTROKES + * SWF_SHAPE_USENONSCALINGSTROKES + */ +PHP_METHOD(swfshape, setRenderHintingFlags) +{ + long flags; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) { + return; + } + + SWFShape_setRenderHintingFlags(getShape(getThis() TSRMLS_CC), flags); +} +/* }}} */ + +/* {{{ proto double swfshape::getPenX() */ +PHP_METHOD(swfshape, getPenX) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_DOUBLE(SWFShape_getPenX(getShape(getThis() TSRMLS_CC))); +} +/* }}} */ + +/* {{{ proto double swfshape::getPenY() */ +PHP_METHOD(swfshape, getPenY) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_DOUBLE(SWFShape_getPenY(getShape(getThis() TSRMLS_CC))); +} +/* }}} */ - if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { +/* {{{ proto void swfshape::hideLine() */ +PHP_METHOD(swfshape, hideLine) +{ + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - convert_to_double_ex(bx); - convert_to_double_ex(by); - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(dx); - convert_to_double_ex(dy); - RETURN_LONG( SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy)) - ); + SWFShape_hideLine(getShape(getThis() TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto void swfshape::drawCharacterBounds(character) */ +PHP_METHOD(swfshape, drawCharacterBounds) +{ + zval *character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &character) == FAILURE) { + return; + } + + SWFShape_drawCharacterBounds(getShape(getThis() TSRMLS_CC), + getCharacter(character TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto void swfshape::setLine2(width, flags, miterLimit, r, g, b, [a]) + * Line cap style: select one of the following flags (default is round cap style) + * SWF_LINESTYLE_CAP_ROUND + * SWF_LINESTYLE_CAP_NONE + * SWF_LINESTYLE_CAP_SQUARE + * + * Line join style: select one of the following flags (default is round join style) + * SWF_LINESTYLE_JOIN_ROUND + * SWF_LINESTYLE_JOIN_BEVEL + * SWF_LINESTYLE_JOIN_MITER + * + * Scaling flags: disable horizontal / vertical scaling + * SWF_LINESTYLE_FLAG_NOHSCALE + * SWF_LINESTYLE_FLAG_NOVSCALE + * + * Enable pixel hinting to correct blurry vertical / horizontal lines + * -> all anchors will be aligned to full pixels + * SWF_LINESTYLE_FLAG_HINTING + * + * Disable stroke closure: if no-close flag is set caps will be applied + * instead of joins + * SWF_LINESTYLE_FLAG_NOCLOSE + * + * End-cap style: default round + * SWF_LINESTYLE_FLAG_ENDCAP_ROUND + * SWF_LINESTYLE_FLAG_ENDCAP_NONE + * SWF_LINESTYLE_FLAG_ENDCAP_SQUARE + * + * If join style is SWF_LINESTYLE_JOIN_MITER a miter limit factor + * must be set. Miter max length is then calculated as: + * max miter len = miter limit * width. + * If join style is not miter, this value will be ignored. + * */ +PHP_METHOD(swfshape, setLine2) +{ + long width, flags, r, g, b, a = 0xff; + double limit; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lldlll|l", &width, &flags, &limit, &r, &g, &b, &a) == FAILURE) { + return; + } + + SWFShape_setLine2(getShape(getThis() TSRMLS_CC), width, r, g, b, a, flags, limit); +} +/* }}} */ + +/* {{{ proto void swfshape::setLine2Filled(width, fill, flags, limit) + * Line cap style: select one of the following flags (default is round cap style) + * SWF_LINESTYLE_CAP_ROUND + * SWF_LINESTYLE_CAP_NONE + * SWF_LINESTYLE_CAP_SQUARE + * + * Line join style: select one of the following flags (default is round join style) + * SWF_LINESTYLE_JOIN_ROUND + * SWF_LINESTYLE_JOIN_BEVEL + * SWF_LINESTYLE_JOIN_MITER + * + * Scaling flags: disable horizontal / vertical scaling + * SWF_LINESTYLE_FLAG_NOHSCALE + * SWF_LINESTYLE_FLAG_NOVSCALE + * + * Enable pixel hinting to correct blurry vertical / horizontal lines + * -> all anchors will be aligned to full pixels + * SWF_LINESTYLE_FLAG_HINTING + * + * Disable stroke closure: if no-close flag is set caps will be applied + * instead of joins + * SWF_LINESTYLE_FLAG_NOCLOSE + * + * End-cap style: default round + * SWF_LINESTYLE_FLAG_ENDCAP_ROUND + * SWF_LINESTYLE_FLAG_ENDCAP_NONE + * SWF_LINESTYLE_FLAG_ENDCAP_SQUARE + * + * If join style is SWF_LINESTYLE_JOIN_MITER a miter limit factor + * must be set. Miter max length is then calculated as: + * max miter len = miter limit * width. + * If join style is not miter, this value will be ignored. + */ +PHP_METHOD(swfshape, setLine2Filled) +{ + long width, flags; + zval *fill; + double limit; + SWFFill xfill; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lold", &width, &fill, &flags, &limit) == FAILURE) { + return; + } + + xfill = getFill(fill TSRMLS_CC); + SWFShape_setLine2Filled(getShape(getThis() TSRMLS_CC), width, SWFFill_getFillStyle(xfill), flags, limit); } /* }}} */ -/* {{{ proto void swfshape::drawcubic(float bx, float by, float cx, float cy, float dx, float dy) - Draws a cubic bezier curve using the current position and the three given points as control points */ -PHP_METHOD(swfshape, drawCubicTo) +/* {{{ */ +PHP_METHOD(swfshape, dumpOutline) { - zval **bx, **by, **cx, **cy, **dx, **dy; - - if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + char *out; + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - convert_to_double_ex(bx); - convert_to_double_ex(by); - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(dx); - convert_to_double_ex(dy); - RETURN_LONG( SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy)) - ); + out = SWFShape_dumpOutline(getShape(getThis() TSRMLS_CC)); + RETURN_STRING(out, 1); + free(out); } /* }}} */ @@ -3304,6 +5164,9 @@ static zend_function_entry swfshape_func PHP_ME(swfshape, __construct, NULL, 0) PHP_ME(swfshape, setLine, NULL, 0) PHP_ME(swfshape, addFill, NULL, 0) + PHP_ME(swfshape, addSolidFill, NULL, 0) + PHP_ME(swfshape, addBitmapFill, NULL, 0) + PHP_ME(swfshape, addGradientFill, NULL, 0) PHP_ME(swfshape, setLeftFill, NULL, 0) PHP_ME(swfshape, setRightFill, NULL, 0) PHP_ME(swfshape, movePenTo, NULL, 0) @@ -3317,6 +5180,16 @@ static zend_function_entry swfshape_func PHP_ME(swfshape, drawArc, NULL, 0) PHP_ME(swfshape, drawCubic, NULL, 0) PHP_ME(swfshape, drawCubicTo, NULL, 0) + PHP_ME(swfshape, end, NULL, 0) + PHP_ME(swfshape, useVersion, NULL, 0) + PHP_ME(swfshape, setRenderHintingFlags, NULL, 0) + PHP_ME(swfshape, getPenX, NULL, 0) + PHP_ME(swfshape, getPenY, NULL, 0) + PHP_ME(swfshape, hideLine, NULL, 0) + PHP_ME(swfshape, drawCharacterBounds, NULL, 0) + PHP_ME(swfshape, setLine2, NULL, 0) + PHP_ME(swfshape, setLine2Filled, NULL, 0) + PHP_ME(swfshape, dumpOutline, NULL, 0) { NULL, NULL, NULL } }; @@ -3349,7 +5222,7 @@ static SWFMovieClip getSprite(zval *id T void *sprite = SWFgetProperty(id, "sprite", 6, le_swfspritep TSRMLS_CC); if (!sprite) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFSprite"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFSprite"); } return (SWFMovieClip)sprite; } @@ -3359,22 +5232,20 @@ static SWFMovieClip getSprite(zval *id T Adds the character to the sprite, returns a displayitem object */ PHP_METHOD(swfsprite, add) { - zval **zchar; + zval *zchar; int ret; SWFBlock block; SWFDisplayItem item; SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; } - - convert_to_object_ex(zchar); - if (Z_OBJCE_PP(zchar) == action_class_entry_ptr) { - block = (SWFBlock)getAction(*zchar TSRMLS_CC); + if (Z_OBJCE_P(zchar) == action_class_entry_ptr) { + block = (SWFBlock)getAction(zchar TSRMLS_CC); } else { - block = (SWFBlock)getCharacter(*zchar TSRMLS_CC); + block = (SWFBlock)getCharacter(zchar TSRMLS_CC); } item = SWFMovieClip_add(sprite, block); @@ -3393,15 +5264,15 @@ PHP_METHOD(swfsprite, add) Remove the named character from the sprite's display list */ PHP_METHOD(swfsprite, remove) { - zval **zchar; + zval *zchar; SWFDisplayItem item; SWFMovieClip movie = getSprite(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; } - convert_to_object_ex(zchar); - item = getDisplayItem(*zchar TSRMLS_CC); + + item = getDisplayItem(zchar TSRMLS_CC); SWFMovieClip_remove(movie, item); } /* }}} */ @@ -3418,13 +5289,14 @@ PHP_METHOD(swfsprite, nextFrame) Labels frame */ PHP_METHOD(swfsprite, labelFrame) { - zval **label; + char *label; + int label_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &label) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &label, &label_len) == FAILURE) { + return; } - convert_to_string_ex(label); - SWFMovieClip_labelFrame(getSprite(getThis() TSRMLS_CC), Z_STRVAL_PP(label)); + + SWFMovieClip_labelFrame(getSprite(getThis() TSRMLS_CC), label); } /* }}} */ @@ -3432,14 +5304,14 @@ PHP_METHOD(swfsprite, labelFrame) Sets the number of frames in this SWFSprite */ PHP_METHOD(swfsprite, setFrames) { - zval **frames; + long frames; SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &frames) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &frames) == FAILURE) { + return; } - convert_to_long_ex(frames); - SWFMovieClip_setNumberOfFrames(sprite, Z_LVAL_PP(frames)); + + SWFMovieClip_setNumberOfFrames(sprite, frames); } /* }}} */ @@ -3448,17 +5320,16 @@ PHP_METHOD(swfsprite, setFrames) PHP_METHOD(swfsprite, startSound) { - zval **zsound; + zval *zsound; int ret; SWFSound sound; SWFSoundInstance item; SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_object_ex(zsound); - sound = (SWFSound)getSound(*zsound TSRMLS_CC); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) { + return; + } + sound = (SWFSound)getSound(zsound TSRMLS_CC); item = SWFMovieClip_startSound(sprite, sound); @@ -3476,31 +5347,148 @@ PHP_METHOD(swfsprite, startSound) PHP_METHOD(swfsprite, stopSound) { - zval **zsound; + zval *zsound; SWFSound sound; SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) { + return; + } + sound = (SWFSound)getSound(zsound TSRMLS_CC); + + SWFMovieClip_stopSound(sprite, sound); +} +/* }}} */ + +/* {{{ proto long swfmovieclip::setSoundStream(mixed file, rate[, skip]) + Sets sound stream of the SWF movieClip. The parameter can be stream or string. */ +PHP_METHOD(swfsprite, setSoundStream) +{ + zval *zfile; + double rate, skip = 0; + SWFSoundStream sound = NULL; + SWFInput input = NULL; + SWFMovieClip mc = getSprite(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zd|d", &zfile, &rate, &skip) == FAILURE) { + return; + } + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + if ( isInput(zfile TSRMLS_CC) ) + { + input = getInput(zfile TSRMLS_CC); + } + else + { + sound = getSoundStream(zfile TSRMLS_CC); + } + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening sound file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + } + + if ( input ) { + sound = newSWFSoundStream_fromInput(input); + } else if ( ! sound ) { + php_error(E_ERROR, "swfmovieclip::setSoundStream: " + "need either a filename, " + "a file ressource, " + "an SWFInput buffer or an SWFSoundStream"); + } + SWFMovieClip_setSoundStreamAt(mc, sound, rate, skip); + RETURN_LONG(SWFSoundStream_getDuration(sound) / rate); +} +/* }}} */ + + +/* {{{ proto void swfsprite::setScalingGrid(int x, int y, int w, int h) */ +PHP_METHOD(swfsprite, setScalingGrid) +{ + long zx, zy, zw, zh; + SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &zx, &zy, &zw, &zh) == FAILURE) { + return; + } + + SWFMovieClip_setScalingGrid(sprite, zx, zy, zw, zh); +} +/* }}} */ + +/* {{{ proto void swfsprite::removeScalingGrid() */ +PHP_METHOD(swfsprite, removeScalingGrid) +{ + SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; + } + + SWFMovieClip_removeScalingGrid(sprite); +} +/* }}} */ - convert_to_object_ex(zsound); - sound = (SWFSound)getSound(*zsound TSRMLS_CC); +/* {{{ proto void swfsprite::addInitAction(action) */ +PHP_METHOD(swfsprite, addInitAction) +{ + zval *zaction; - SWFMovieClip_stopSound(sprite, sound); + SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); + SWFAction action; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zaction) == FAILURE) { + return; + } + + action = getAction(zaction TSRMLS_CC); + SWFMovieClip_addInitAction(sprite, action); } /* }}} */ #endif +// workaround to support SWFSprite and SWFMovieclip objects +static zend_function_entry swfmovieclip_functions[] = { + PHP_ME(swfsprite, __construct, NULL, 0) + PHP_ME(swfsprite, add, NULL, 0) + PHP_ME(swfsprite, remove, NULL, 0) + PHP_ME(swfsprite, nextFrame, NULL, 0) + PHP_ME(swfsprite, labelFrame, NULL, 0) + PHP_ME(swfsprite, setFrames, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swfsprite, startSound, NULL, 0) + PHP_ME(swfsprite, stopSound, NULL, 0) + PHP_ME(swfsprite, setScalingGrid, NULL, 0) + PHP_ME(swfsprite, removeScalingGrid, NULL, 0) + PHP_ME(swfsprite, setSoundStream, NULL, 0) + PHP_ME(swfsprite, addInitAction, NULL, 0) +#endif + { NULL, NULL, NULL } +}; + static zend_function_entry swfsprite_functions[] = { PHP_ME(swfsprite, __construct, NULL, 0) - PHP_ME(swfsprite, add, NULL, 0) - PHP_ME(swfsprite, remove, NULL, 0) + PHP_ME(swfsprite, add, NULL, 0) + PHP_ME(swfsprite, remove, NULL, 0) PHP_ME(swfsprite, nextFrame, NULL, 0) PHP_ME(swfsprite, labelFrame, NULL, 0) PHP_ME(swfsprite, setFrames, NULL, 0) #ifdef HAVE_NEW_MING PHP_ME(swfsprite, startSound, NULL, 0) PHP_ME(swfsprite, stopSound, NULL, 0) + PHP_ME(swfsprite, setScalingGrid, NULL, 0) + PHP_ME(swfsprite, removeScalingGrid, NULL, 0) + PHP_ME(swfsprite, setSoundStream, NULL, 0) + PHP_ME(swfsprite, addInitAction, NULL, 0) #endif { NULL, NULL, NULL } }; @@ -3509,13 +5497,24 @@ static zend_function_entry swfsprite_fun /* {{{ SWFText */ -/* {{{ proto void swftext::__construct() +/* {{{ proto void swftext::__construct([version]) Creates new SWFText object */ PHP_METHOD(swftext, __construct) { - SWFText text = newSWFText2(); - int ret = zend_list_insert(text, le_swftextp); + long version = 0; + SWFText text; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &version) == FAILURE) { + return; + } + if (version == 1) { + text = newSWFText(); + } + else { + text = newSWFText2(); + } + int ret = zend_list_insert(text, le_swftextp); object_init_ex(getThis(), text_class_entry_ptr); add_property_resource(getThis(), "text", ret); zend_list_addref(ret); @@ -3534,25 +5533,25 @@ static SWFText getText(zval *id TSRMLS_D void *text = SWFgetProperty(id, "text", 4, le_swftextp TSRMLS_CC); if (!text) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFText"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFText"); } return (SWFText)text; } /* }}} */ -/* {{{ proto void swftext::setFont(object font) +/* {{{ proto void swftext::setFont(SWFFont font) Sets this SWFText object's current font to given font */ PHP_METHOD(swftext, setFont) { - zval **zfont; + zval *zfont; SWFText text = getText(getThis() TSRMLS_CC); SWFFont font; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfont) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfont) == FAILURE) { + return; } - convert_to_object_ex(zfont); - font = getFont(*zfont TSRMLS_CC); + + font = getFont(zfont TSRMLS_CC); SWFText_setFont(text, font); } /* }}} */ @@ -3561,14 +5560,14 @@ PHP_METHOD(swftext, setFont) Sets this SWFText object's current height to given height */ PHP_METHOD(swftext, setHeight) { - zval **height; + double height; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &height) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &height) == FAILURE) { + return; } - convert_to_double_ex(height); - SWFText_setHeight(text, FLOAT_Z_DVAL_PP(height)); + + SWFText_setHeight(text, height); } /* }}} */ @@ -3576,14 +5575,14 @@ PHP_METHOD(swftext, setHeight) Sets this SWFText object's current letterspacing to given spacing */ PHP_METHOD(swftext, setSpacing) { - zval **spacing; + double spacing; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &spacing) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &spacing) == FAILURE) { + return; } - convert_to_double_ex(spacing); - SWFText_setSpacing(text, FLOAT_Z_DVAL_PP(spacing)); + + SWFText_setSpacing(text, spacing); } /* }}} */ @@ -3591,30 +5590,14 @@ PHP_METHOD(swftext, setSpacing) Sets this SWFText object's current color to the given color */ PHP_METHOD(swftext, setColor) { - zval **r, **g, **b, **a; + long r, g, b, a = 0xff; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(a); - } else { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - if (ZEND_NUM_ARGS() == 4) { - SWFText_setColor(text, BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a)); - } else { - SWFText_setColor(text, BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff); - } + SWFText_setColor(text, (byte)r, (byte)g, (byte)b, (byte)a); } /* }}} */ @@ -3622,15 +5605,14 @@ PHP_METHOD(swftext, setColor) Moves this SWFText object's current pen position to (x, y) in text coordinates */ PHP_METHOD(swftext, moveTo) { - zval **x, **y; + double x, y; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFText_setXY(text, FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFText_setXY(text, x, y); } /* }}} */ @@ -3638,15 +5620,15 @@ PHP_METHOD(swftext, moveTo) Writes the given text into this SWFText object at the current pen position, using the current font, height, spacing, and color */ PHP_METHOD(swftext, addString) { - zval **s; + char *s; + int s_len; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &s_len) == FAILURE) { + return; } - convert_to_string_ex(s); - SWFText_addString(text, Z_STRVAL_PP(s), NULL); + SWFText_addString(text, s, NULL); } /* }}} */ @@ -3657,15 +5639,15 @@ PHP_METHOD(swftext, addString) PHP_METHOD(swftext, addUTF8String) { - zval **s; + char *s; + int s_len; SWFText text = getText(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(s); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &s_len) == FAILURE) { + return; + } - SWFText_addUTF8String(text, Z_STRVAL_PP(s), NULL); + SWFText_addUTF8String(text, s, NULL); } /* }}} */ @@ -3675,15 +5657,15 @@ PHP_METHOD(swftext, addUTF8String) /* PHP_METHOD(swftext, addWideString) { - zval **s; + char *s; + int s_len; SWFText text = getText(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(s); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &s_len) == FAILURE) { + return; + } - SWFText_addWideString(text, Z_STRVAL_PP(s), NULL); + SWFText_addWideString(text, s, NULL); } */ /* }}} */ @@ -3693,13 +5675,14 @@ PHP_METHOD(swftext, addWideString) Calculates the width of the given string in this text objects current font and size */ PHP_METHOD(swftext, getWidth) { - zval **zstring; + char *string; + int string_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; } - convert_to_string_ex(zstring); - RETURN_DOUBLE(SWFText_getStringWidth(getText(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring))); + + RETURN_DOUBLE(SWFText_getStringWidth(getText(getThis() TSRMLS_CC), string)); } /* }}} */ @@ -3709,17 +5692,14 @@ PHP_METHOD(swftext, getWidth) PHP_METHOD(swftext, getUTF8Width) { - zval **zstring; - int width; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(zstring); - - width = SWFText_getUTF8StringWidth(getText(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + char *string; + int string_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } - RETURN_DOUBLE(width); + RETURN_DOUBLE(SWFText_getUTF8StringWidth(getText(getThis() TSRMLS_CC), string)); } /* }}} */ @@ -3728,17 +5708,14 @@ PHP_METHOD(swftext, getUTF8Width) /* PHP_METHOD(swftext, getWideWidth) { - zval **zstring; - int width; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(zstring); - - width = SWFText_getWideStringWidth(getText(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); - - RETURN_DOUBLE(width); + char *string; + int string_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } + + RETURN_DOUBLE(SWFText_getWideStringWidth(getText(getThis() TSRMLS_CC), string)); } */ /* }}} */ @@ -3762,7 +5739,7 @@ PHP_METHOD(swftext, getDescent) if(ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - RETURN_DOUBLE(SWFText_getDescent(getText(getThis() TSRMLS_CC))); + RETURN_DOUBLE(SWFText_getDescent(getText(getThis() TSRMLS_CC))); } /* }}} */ @@ -3773,7 +5750,7 @@ PHP_METHOD(swftext, getLeading) if(ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - RETURN_DOUBLE(SWFText_getLeading(getText(getThis() TSRMLS_CC))); + RETURN_DOUBLE(SWFText_getLeading(getText(getThis() TSRMLS_CC))); } /* }}} */ @@ -3808,7 +5785,7 @@ static zend_function_entry swftext_funct Creates a new SWFTextField object */ PHP_METHOD(swftextfield, __construct) { - zval **flags; + long flags = 0; SWFTextField field = newSWFTextField(); int ret = zend_list_insert(field, le_swftextfieldp); @@ -3816,13 +5793,11 @@ PHP_METHOD(swftextfield, __construct) add_property_resource(getThis(), "textfield", ret); zend_list_addref(ret); - if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &flags) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(flags); - SWFTextField_setFlags(field, Z_LVAL_PP(flags)); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) { + return; } + + SWFTextField_setFlags(field, flags); } /* }}} */ @@ -3838,7 +5813,7 @@ static SWFTextField getTextField(zval *i void *field = SWFgetProperty(id, "textfield", 9, le_swftextfieldp TSRMLS_CC); if (!field) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFTextField"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFTextField"); } return (SWFTextField)field; } @@ -3861,14 +5836,25 @@ SWFBlock getFontOrFontChar(zval *id TSRM PHP_METHOD(swftextfield, setFont) { - zval **font; + zval *font; SWFTextField field = getTextField(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &font) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &font) == FAILURE) { + return; + } + + if(Z_OBJCE_P(font) == font_class_entry_ptr + || Z_OBJCE_P(font) == fontchar_class_entry_ptr) + { + SWFTextField_setFont(field, getFontOrFontChar(font TSRMLS_CC)); + } + else if(Z_OBJCE_P(font) == browserfont_class_entry_ptr) + { + SWFTextField_setFont(field, (SWFBlock)getBrowserFont(font TSRMLS_CC)); } - convert_to_object_ex(font); - SWFTextField_setFont(field, getFontOrFontChar(*font TSRMLS_CC)); + else { + php_error(E_ERROR, "not a font object\n"); + } } /* }}} */ @@ -3876,15 +5862,28 @@ PHP_METHOD(swftextfield, setFont) Sets the width and height of this textfield */ PHP_METHOD(swftextfield, setBounds) { - zval **width, **height; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double width, height; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &width, &height) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &width, &height) == FAILURE) { + return; + } + + SWFTextField_setBounds(getTextField(getThis() TSRMLS_CC), width, height); +} +/* }}} */ + +/* {{{ proto void swftextfield::setFlags(int flags) + Sets the flags for this textfield */ +PHP_METHOD(swftextfield, setFlags) +{ + long flags; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) { + return; } - convert_to_double_ex(width); - convert_to_double_ex(height); - SWFTextField_setBounds(field, FLOAT_Z_DVAL_PP(width), FLOAT_Z_DVAL_PP(height)); + + SWFTextField_setFlags(getTextField(getThis() TSRMLS_CC), flags); + } /* }}} */ @@ -3892,14 +5891,13 @@ PHP_METHOD(swftextfield, setBounds) Sets the alignment of this textfield */ PHP_METHOD(swftextfield, align) { - zval **align; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + long align; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &align) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &align) == FAILURE) { + return; } - convert_to_long_ex(align); - SWFTextField_setAlignment(field, Z_LVAL_PP(align)); + + SWFTextField_setAlignment(getTextField(getThis() TSRMLS_CC), align); } /* }}} */ @@ -3907,14 +5905,13 @@ PHP_METHOD(swftextfield, align) Sets the font height of this textfield */ PHP_METHOD(swftextfield, setHeight) { - zval **height; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double height; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &height) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &height) == FAILURE) { + return; } - convert_to_double_ex(height); - SWFTextField_setHeight(field, FLOAT_Z_DVAL_PP(height)); + + SWFTextField_setHeight(getTextField(getThis() TSRMLS_CC), height); } /* }}} */ @@ -3922,14 +5919,13 @@ PHP_METHOD(swftextfield, setHeight) Sets the left margin of this textfield */ PHP_METHOD(swftextfield, setLeftMargin) { - zval **margin; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double margin; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &margin) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &margin) == FAILURE) { + return; } - convert_to_double_ex(margin); - SWFTextField_setLeftMargin(field, FLOAT_Z_DVAL_PP(margin)); + + SWFTextField_setLeftMargin(getTextField(getThis() TSRMLS_CC), margin); } /* }}} */ @@ -3937,14 +5933,13 @@ PHP_METHOD(swftextfield, setLeftMargin) Sets the right margin of this textfield */ PHP_METHOD(swftextfield, setRightMargin) { - zval **margin; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double margin; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &margin) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &margin) == FAILURE) { + return; } - convert_to_double_ex(margin); - SWFTextField_setRightMargin(field, FLOAT_Z_DVAL_PP(margin)); + + SWFTextField_setRightMargin(getTextField(getThis() TSRMLS_CC), margin); } /* }}} */ @@ -3952,16 +5947,15 @@ PHP_METHOD(swftextfield, setRightMargin) Sets both margins of this textfield */ PHP_METHOD(swftextfield, setMargins) { - zval **left, **right; + double left, right; SWFTextField field = getTextField(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &left, &right) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &left, &right) == FAILURE) { + return; } - convert_to_double_ex(left); - convert_to_double_ex(right); - SWFTextField_setLeftMargin(field, FLOAT_Z_DVAL_PP(left)); - SWFTextField_setRightMargin(field, FLOAT_Z_DVAL_PP(right)); + + SWFTextField_setLeftMargin(field, left); + SWFTextField_setRightMargin(field, right); } /* }}} */ @@ -3969,14 +5963,13 @@ PHP_METHOD(swftextfield, setMargins) Sets the indentation of the first line of this textfield */ PHP_METHOD(swftextfield, setIndentation) { - zval **indent; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double indent; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &indent) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &indent) == FAILURE) { + return; } - convert_to_double_ex(indent); - SWFTextField_setIndentation(field, FLOAT_Z_DVAL_PP(indent)); + + SWFTextField_setIndentation(getTextField(getThis() TSRMLS_CC), indent); } /* }}} */ @@ -3984,14 +5977,13 @@ PHP_METHOD(swftextfield, setIndentation) Sets the line spacing of this textfield */ PHP_METHOD(swftextfield, setLineSpacing) { - zval **spacing; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double spacing; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &spacing) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &spacing) == FAILURE) { + return; } - convert_to_double_ex(spacing); - SWFTextField_setLineSpacing(field, FLOAT_Z_DVAL_PP(spacing)); + + SWFTextField_setLineSpacing(getTextField(getThis() TSRMLS_CC), spacing); } /* }}} */ @@ -3999,27 +5991,12 @@ PHP_METHOD(swftextfield, setLineSpacing) Sets the color of this textfield */ PHP_METHOD(swftextfield, setColor) { - zval **r, **g, **b, **a; - SWFTextField field = getTextField(getThis() TSRMLS_CC); - byte alpha = 0xff; + long r, g, b, a = 0xff; - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(a); - alpha = BYTE_Z_LVAL_PP(a); - } else { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - SWFTextField_setColor(field, BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), (byte)alpha); + SWFTextField_setColor(getTextField(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a); } /* }}} */ @@ -4027,14 +6004,14 @@ PHP_METHOD(swftextfield, setColor) Sets the variable name of this textfield */ PHP_METHOD(swftextfield, setName) { - zval **name; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + char *name; + int name_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &name) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + return; } - convert_to_string_ex(name); - SWFTextField_setVariableName(field, Z_STRVAL_PP(name)); + + SWFTextField_setVariableName(getTextField(getThis() TSRMLS_CC), name); } /* }}} */ @@ -4042,31 +6019,45 @@ PHP_METHOD(swftextfield, setName) Adds the given string to this textfield */ PHP_METHOD(swftextfield, addString) { - zval **string; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + char *str; + int str_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &string) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; + } + + SWFTextField_addString(getTextField(getThis() TSRMLS_CC), str); +} +/* }}} */ + +/* {{{ proto void swftextfield::addUTF8String(string str) + Adds the given UTF8 string to this textfield */ +PHP_METHOD(swftextfield, addUTF8String) +{ + char *str; + int str_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; } - convert_to_string_ex(string); - SWFTextField_addString(field, Z_STRVAL_PP(string)); + + SWFTextField_addUTF8String(getTextField(getThis() TSRMLS_CC), str); } /* }}} */ + #ifdef HAVE_NEW_MING /* {{{ proto void swftextfield::setPadding(float padding) Sets the padding of this textfield */ PHP_METHOD(swftextfield, setPadding) { - zval **padding; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double padding; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &padding) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_double_ex(padding); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &padding) == FAILURE) { + return; + } - SWFTextField_setPadding(field, Z_DVAL_PP(padding)); + SWFTextField_setPadding(getTextField(getThis() TSRMLS_CC), padding); } /* }}} */ @@ -4074,24 +6065,51 @@ PHP_METHOD(swftextfield, setPadding) adds characters to a font that will be available within a textfield */ PHP_METHOD(swftextfield, addChars) { - zval **zstring; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + char *str; + int str_len; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; + } + + SWFTextField_addChars(getTextField(getThis() TSRMLS_CC), str); + +} +/* }}} */ + +/* {{{ proto void swftextfield::setLength(int len) */ +PHP_METHOD(swftextfield, setLength) +{ + long len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &len) == FAILURE) { + return; + } + + SWFTextField_setLength(getTextField(getThis() TSRMLS_CC), len); +} +/* }}} */ - convert_to_string_ex(zstring); +/* {{{ proto void swftextfield::setLength(len) */ +PHP_METHOD(swftextfield, setFieldHeight) +{ + long h; - SWFTextField_addChars(field, Z_STRVAL_PP(zstring)); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &h) == FAILURE) { + return; + } + SWFTextField_setFieldHeight(getTextField(getThis() TSRMLS_CC), h); } /* }}} */ + #endif static zend_function_entry swftextfield_functions[] = { PHP_ME(swftextfield, __construct, NULL, 0) PHP_ME(swftextfield, setFont, NULL, 0) PHP_ME(swftextfield, setBounds, NULL, 0) + PHP_ME(swftextfield, setFlags, NULL, 0) PHP_ME(swftextfield, align, NULL, 0) PHP_ME(swftextfield, setHeight, NULL, 0) PHP_ME(swftextfield, setLeftMargin, NULL, 0) @@ -4102,9 +6120,12 @@ static zend_function_entry swftextfield_ PHP_ME(swftextfield, setColor, NULL, 0) PHP_ME(swftextfield, setName, NULL, 0) PHP_ME(swftextfield, addString, NULL, 0) + PHP_ME(swftextfield, addUTF8String, NULL, 0) #ifdef HAVE_NEW_MING PHP_ME(swftextfield, setPadding, NULL, 0) PHP_ME(swftextfield, addChars, NULL, 0) + PHP_ME(swftextfield, setLength, NULL, 0) + PHP_ME(swftextfield, setFieldHeight, NULL, 0) #endif { NULL, NULL, NULL } }; @@ -4139,11 +6160,28 @@ PHP_MINFO_FUNCTION(ming) } /* }}} */ -/* {{{ todo PHP_MINIT_FUNCTION(ming) -*/ +#if PHP_API_VERSION == 20020918 +static php4_fix_funcnames(char *class_name, zend_function_entry *funcs) /* {{{ */ +{ + zend_function_entry *pf = funcs; + char *pname; + + while(funcs->fname) { + if( strcmp(funcs->fname,"__construct") == 0 ) { + pname=strdup(class_name); + } else { + pname=strdup(funcs->fname); + } + funcs->fname=pname; + while(*pname) { *pname=tolower(*pname);pname++;} + funcs++; + } +} +/* }}} */ +#endif /* custom error handler propagates ming errors up to php */ -static void php_ming_error(const char *msg, ...) +static void php_ming_error(const char *msg, ...) /* {{{ */ { va_list args; char *buffer; @@ -4154,21 +6192,25 @@ static void php_ming_error(const char *m vspprintf(&buffer, 0, msg, args); va_end(args); - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "%s", buffer); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "%s", buffer); efree(buffer); } +/* }}} */ -PHP_RINIT_FUNCTION(ming) +PHP_RINIT_FUNCTION(ming) /* {{{ */ { /* XXX - this didn't work so well last I tried.. */ if (Ming_init() != 0) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Error initializing Ming module"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error initializing Ming module"); return FAILURE; } return SUCCESS; } +/* }}} */ +/* {{{ todo PHP_MINIT_FUNCTION(ming) +*/ PHP_MINIT_FUNCTION(ming) { zend_class_entry shape_class_entry; @@ -4183,17 +6225,29 @@ PHP_MINIT_FUNCTION(ming) zend_class_entry button_class_entry; zend_class_entry action_class_entry; zend_class_entry morph_class_entry; + zend_class_entry movieclip_class_entry; zend_class_entry sprite_class_entry; zend_class_entry sound_class_entry; #ifdef HAVE_NEW_MING zend_class_entry fontchar_class_entry; zend_class_entry soundinstance_class_entry; zend_class_entry videostream_class_entry; -#endif -#ifdef HAVE_SWFPREBUILTCLIP + zend_class_entry buttonrecord_class_entry; + zend_class_entry binarydata_class_entry; + zend_class_entry initaction_class_entry; zend_class_entry prebuiltclip_class_entry; + zend_class_entry soundstream_class_entry; + zend_class_entry filter_class_entry; + zend_class_entry filtermatrix_class_entry; + zend_class_entry blur_class_entry; + zend_class_entry shadow_class_entry; + zend_class_entry cxform_class_entry; + zend_class_entry matrix_class_entry; + zend_class_entry input_class_entry; + zend_class_entry browserfont_class_entry; + zend_class_entry fontcollection_class_entry; #endif - + zend_class_entry character_class_entry; Ming_setErrorFunction((void *) php_ming_error); #define CONSTANT(s,c) REGISTER_LONG_CONSTANT((s), (c), CONST_CS | CONST_PERSISTENT) @@ -4228,9 +6282,12 @@ PHP_MINIT_FUNCTION(ming) CONSTANT("SWFFILL_LINEAR_GRADIENT", SWFFILL_LINEAR_GRADIENT); CONSTANT("SWFFILL_TILED_BITMAP", SWFFILL_TILED_BITMAP); CONSTANT("SWFFILL_CLIPPED_BITMAP", SWFFILL_CLIPPED_BITMAP); + CONSTANT("SWFFILL_NONSMOOTHED_TILED_BITMAP", + SWFFILL_NONSMOOTHED_TILED_BITMAP); + CONSTANT("SWFFILL_NONSMOOTHED_CLIPPED_BITMAP", + SWFFILL_NONSMOOTHED_CLIPPED_BITMAP); /* flags for SWFTextField_init */ - CONSTANT("SWFTEXTFIELD_HASLENGTH", SWFTEXTFIELD_HASLENGTH); CONSTANT("SWFTEXTFIELD_NOEDIT", SWFTEXTFIELD_NOEDIT); CONSTANT("SWFTEXTFIELD_PASSWORD", SWFTEXTFIELD_PASSWORD); CONSTANT("SWFTEXTFIELD_MULTILINE", SWFTEXTFIELD_MULTILINE); @@ -4238,7 +6295,6 @@ PHP_MINIT_FUNCTION(ming) CONSTANT("SWFTEXTFIELD_DRAWBOX", SWFTEXTFIELD_DRAWBOX); CONSTANT("SWFTEXTFIELD_NOSELECT", SWFTEXTFIELD_NOSELECT); CONSTANT("SWFTEXTFIELD_HTML", SWFTEXTFIELD_HTML); - CONSTANT("SWFTEXTFIELD_USEFONT", SWFTEXTFIELD_USEFONT); CONSTANT("SWFTEXTFIELD_AUTOSIZE", SWFTEXTFIELD_AUTOSIZE); /* flags for SWFTextField_align */ @@ -4257,6 +6313,15 @@ PHP_MINIT_FUNCTION(ming) CONSTANT("SWFACTION_KEYDOWN", SWFACTION_KEYDOWN); CONSTANT("SWFACTION_KEYUP", SWFACTION_KEYUP); CONSTANT("SWFACTION_DATA", SWFACTION_DATA); + CONSTANT("SWFACTION_INIT", SWFACTION_INIT); + CONSTANT("SWFACTION_PRESS", SWFACTION_PRESS); + CONSTANT("SWFACTION_RELEASE", SWFACTION_RELEASE); + CONSTANT("SWFACTION_RELEASEOUTSIDE", SWFACTION_RELEASEOUTSIDE); + CONSTANT("SWFACTION_ROLLOVER", SWFACTION_ROLLOVER); + CONSTANT("SWFACTION_DRAGOVER", SWFACTION_DRAGOVER); + CONSTANT("SWFACTION_DRAGOUT", SWFACTION_DRAGOUT); + CONSTANT("SWFACTION_KEYPRESS", SWFACTION_KEYPRESS); + CONSTANT("SWFACTION_CONSTRUCT", SWFACTION_CONSTRUCT); /* flags for SWFSound */ CONSTANT("SWF_SOUND_NOT_COMPRESSED", SWF_SOUND_NOT_COMPRESSED); @@ -4273,6 +6338,76 @@ PHP_MINIT_FUNCTION(ming) CONSTANT("SWF_SOUND_MONO", SWF_SOUND_MONO); CONSTANT("SWF_SOUND_STEREO", SWF_SOUND_STEREO); +#ifdef HAVE_NEW_MING + /* Blend Modes */ + CONSTANT("SWFBLEND_MODE_NORMAL", SWFBLEND_MODE_NORMAL); + CONSTANT("SWFBLEND_MODE_LAYER", SWFBLEND_MODE_LAYER); + CONSTANT("SWFBLEND_MODE_MULT", SWFBLEND_MODE_MULT); + CONSTANT("SWFBLEND_MODE_SCREEN", SWFBLEND_MODE_SCREEN); + CONSTANT("SWFBLEND_MODE_DARKEN", SWFBLEND_MODE_DARKEN); + CONSTANT("SWFBLEND_MODE_LIGHTEN", SWFBLEND_MODE_LIGHTEN); + CONSTANT("SWFBLEND_MODE_ADD", SWFBLEND_MODE_ADD); + CONSTANT("SWFBLEND_MODE_SUB", SWFBLEND_MODE_SUB); + CONSTANT("SWFBLEND_MODE_DIFF", SWFBLEND_MODE_DIFF); + CONSTANT("SWFBLEND_MODE_INV", SWFBLEND_MODE_INV); + CONSTANT("SWFBLEND_MODE_ALPHA", SWFBLEND_MODE_ALPHA); + CONSTANT("SWFBLEND_MODE_ERASE", SWFBLEND_MODE_ERASE); + CONSTANT("SWFBLEND_MODE_OVERLAY", SWFBLEND_MODE_OVERLAY); + CONSTANT("SWFBLEND_MODE_HARDLIGHT", SWFBLEND_MODE_HARDLIGHT); + + /* filter types */ + CONSTANT("SWFFILTER_TYPE_DROPSHADOW", SWFFILTER_TYPE_DROPSHADOW); + CONSTANT("SWFFILTER_TYPE_BLUR", SWFFILTER_TYPE_BLUR); + CONSTANT("SWFFILTER_TYPE_GLOW", SWFFILTER_TYPE_GLOW); + CONSTANT("SWFFILTER_TYPE_BEVEL", SWFFILTER_TYPE_BEVEL); + CONSTANT("SWFFILTER_TYPE_GRADIENTGLOW", SWFFILTER_TYPE_GRADIENTGLOW); + CONSTANT("SWFFILTER_TYPE_CONVOLUTION", SWFFILTER_TYPE_CONVOLUTION); + CONSTANT("SWFFILTER_TYPE_COLORMATRIX", SWFFILTER_TYPE_COLORMATRIX); + CONSTANT("SWFFILTER_TYPE_GRADIENTBEVEL", SWFFILTER_TYPE_GRADIENTBEVEL); + + /* filter flags */ + CONSTANT("SWFFILTER_FLAG_CLAMP", FILTER_FLAG_CLAMP); + CONSTANT("SWFFILTER_FLAG_PRESERVE_ALPHA", FILTER_FLAG_PRESERVE_ALPHA); + + /* filter modes */ + CONSTANT("SWFFILTER_MODE_INNER", FILTER_MODE_INNER); + CONSTANT("SWFFILTER_MODE_KO", FILTER_MODE_KO); + CONSTANT("SWFFILTER_MODE_COMPOSITE", FILTER_MODE_COMPOSITE); + CONSTANT("SWFFILTER_MODE_ONTOP", FILTER_MODE_ONTOP); + + /* new gradient features */ + CONSTANT("SWF_GRADIENT_PAD", SWF_GRADIENT_PAD); + CONSTANT("SWF_GRADIENT_REFLECT", SWF_GRADIENT_REFLECT); + CONSTANT("SWF_GRADIENT_REPEAT", SWF_GRADIENT_REPEAT); + CONSTANT("SWF_GRADIENT_NORMAL", SWF_GRADIENT_NORMAL); + CONSTANT("SWF_GRADIENT_LINEAR", SWF_GRADIENT_LINEAR); + + /* shape options */ + CONSTANT("SWF_SHAPE3", SWF_SHAPE3); + CONSTANT("SWF_SHAPE4", SWF_SHAPE4); + CONSTANT("SWF_SHAPE_USESCALINGSTROKES", SWF_SHAPE_USESCALINGSTROKES); + CONSTANT("SWF_SHAPE_USENONSCALINGSTROKES", SWF_SHAPE_USENONSCALINGSTROKES); + + /* linestyle 2 flags */ + CONSTANT("SWF_LINESTYLE_CAP_ROUND", SWF_LINESTYLE_CAP_ROUND); + CONSTANT("SWF_LINESTYLE_CAP_NONE", SWF_LINESTYLE_CAP_NONE); + CONSTANT("SWF_LINESTYLE_CAP_SQUARE", SWF_LINESTYLE_CAP_SQUARE); + CONSTANT("SWF_LINESTYLE_JOIN_ROUND", SWF_LINESTYLE_JOIN_ROUND); + CONSTANT("SWF_LINESTYLE_JOIN_BEVEL", SWF_LINESTYLE_JOIN_BEVEL); + CONSTANT("SWF_LINESTYLE_JOIN_MITER", SWF_LINESTYLE_JOIN_MITER); + CONSTANT("SWF_LINESTYLE_FLAG_NOHSCALE", SWF_LINESTYLE_FLAG_NOHSCALE); + CONSTANT("SWF_LINESTYLE_FLAG_NOVSCALE", SWF_LINESTYLE_FLAG_NOVSCALE); + CONSTANT("SWF_LINESTYLE_FLAG_HINTING", SWF_LINESTYLE_FLAG_HINTING); + CONSTANT("SWF_LINESTYLE_FLAG_NOCLOSE", SWF_LINESTYLE_FLAG_NOCLOSE); + CONSTANT("SWF_LINESTYLE_FLAG_ENDCAP_ROUND", SWF_LINESTYLE_FLAG_ENDCAP_ROUND); + CONSTANT("SWF_LINESTYLE_FLAG_ENDCAP_NONE", SWF_LINESTYLE_FLAG_ENDCAP_NONE); + CONSTANT("SWF_LINESTYLE_FLAG_ENDCAP_SQUARE", SWF_LINESTYLE_FLAG_ENDCAP_SQUARE); + + /* flags for SWFVideo */ + CONSTANT("SWF_VIDEOSTREAM_MODE_MANUAL", SWFVIDEOSTREAM_MODE_MANUAL); + CONSTANT("SWF_VIDEOSTREAM_MODE_AUTO", SWFVIDEOSTREAM_MODE_AUTO); +#endif + le_swfshapep = zend_register_list_destructors_ex(destroy_SWFShape_resource, NULL, "SWFShape", module_number); le_swffillp = zend_register_list_destructors_ex(destroy_SWFFill_resource, NULL, "SWFFill", module_number); le_swfgradientp = zend_register_list_destructors_ex(destroy_SWFGradient_resource, NULL, "SWFGradient", module_number); @@ -4285,17 +6420,29 @@ PHP_MINIT_FUNCTION(ming) le_swfbuttonp = zend_register_list_destructors_ex(destroy_SWFButton_resource, NULL, "SWFButton", module_number); le_swfactionp = zend_register_list_destructors_ex(NULL, NULL, "SWFAction", module_number); le_swfmorphp = zend_register_list_destructors_ex(destroy_SWFMorph_resource, NULL, "SWFMorph", module_number); + le_swfmovieclipp = zend_register_list_destructors_ex(destroy_SWFSprite_resource, NULL, "SWFMovieClip", module_number); le_swfspritep = zend_register_list_destructors_ex(destroy_SWFSprite_resource, NULL, "SWFSprite", module_number); le_swfinputp = zend_register_list_destructors_ex(destroy_SWFInput_resource, NULL, "SWFInput", module_number); le_swfsoundp = zend_register_list_destructors_ex(destroy_SWFSound_resource, NULL, "SWFSound", module_number); #ifdef HAVE_NEW_MING - le_swffontcharp = zend_register_list_destructors_ex(destroy_SWFFontCharacter_resource, NULL, "SWFFontCharacter", module_number); + le_swffontcharp = zend_register_list_destructors_ex(NULL, NULL, "SWFFontCharacter", module_number); + le_swfbuttonrecordp = zend_register_list_destructors_ex(NULL, NULL, "SWFButtonRecord", module_number); le_swfsoundinstancep = zend_register_list_destructors_ex(NULL, NULL, "SWFSoundInstance", module_number); le_swfvideostreamp = zend_register_list_destructors_ex(destroy_SWFVideoStream_resource, NULL, "SWFVideoStream", module_number); -#endif -#ifdef HAVE_SWFPREBUILTCLIP + le_swfbinarydatap = zend_register_list_destructors_ex(destroy_SWFBinaryData_resource, NULL, "SWFBinaryData", module_number); + le_swfinitactionp = zend_register_list_destructors_ex(NULL, NULL, "SWFInitAction", module_number); le_swfprebuiltclipp = zend_register_list_destructors_ex(destroy_SWFPrebuiltClip_resource, NULL, "SWFPrebuiltClip", module_number); + le_swfsoundstreamp = zend_register_list_destructors_ex(destroy_SWFSoundStream_resource, NULL, "SWFSoundStream", module_number); + le_swffilterp = zend_register_list_destructors_ex(destroy_SWFFilter_resource, NULL, "SWFFilter", module_number); + le_swfblurp = zend_register_list_destructors_ex(destroy_SWFBlur_resource, NULL, "SWFBlur", module_number); + le_swfshadowp = zend_register_list_destructors_ex(destroy_SWFShadow_resource, NULL, "SWFShadow", module_number); + le_swffiltermatrixp = zend_register_list_destructors_ex(destroy_SWFFilterMatrix_resource, NULL, "SWFFilterMatrix", module_number); + le_swfcharacterp = zend_register_list_destructors_ex(NULL, NULL, "SWFCharacter", module_number); + le_swfcxformp = zend_register_list_destructors_ex(destroy_SWFCXform_resource, NULL, "SWFCXform", module_number); + le_swfmatrixp = zend_register_list_destructors_ex(NULL, NULL, "SWFMatrix", module_number); + le_swfbrowserfontp = zend_register_list_destructors_ex(destroy_SWFBrowserFont_resource, NULL, "SWFBrowserFont", module_number); + le_swffontcollectionp = zend_register_list_destructors_ex(destroy_SWFFontCollection_resource, NULL, "SWFFontCollection", module_number); #endif INIT_CLASS_ENTRY(shape_class_entry, "SWFShape", swfshape_functions); @@ -4310,16 +6457,30 @@ PHP_MINIT_FUNCTION(ming) INIT_CLASS_ENTRY(button_class_entry, "SWFButton", swfbutton_functions); INIT_CLASS_ENTRY(action_class_entry, "SWFAction", swfaction_functions); INIT_CLASS_ENTRY(morph_class_entry, "SWFMorph", swfmorph_functions); + INIT_CLASS_ENTRY(movieclip_class_entry, "SWFMovieClip", swfmovieclip_functions); INIT_CLASS_ENTRY(sprite_class_entry, "SWFSprite", swfsprite_functions); INIT_CLASS_ENTRY(sound_class_entry, "SWFSound", swfsound_functions); #ifdef HAVE_NEW_MING INIT_CLASS_ENTRY(fontchar_class_entry, "SWFFontChar", swffontchar_functions); + INIT_CLASS_ENTRY(buttonrecord_class_entry, "SWFButtonRecord", swfbuttonrecord_functions); INIT_CLASS_ENTRY(soundinstance_class_entry, "SWFSoundInstance", swfsoundinstance_functions); INIT_CLASS_ENTRY(videostream_class_entry, "SWFVideoStream", swfvideostream_functions); -#endif -#ifdef HAVE_SWFPREBUILTCLIP + INIT_CLASS_ENTRY(binarydata_class_entry, "SWFBinaryData", swfbinarydata_functions); + INIT_CLASS_ENTRY(initaction_class_entry, "SWFInitAction", swfinitaction_functions); INIT_CLASS_ENTRY(prebuiltclip_class_entry, "SWFPrebuiltClip", swfprebuiltclip_functions); + INIT_CLASS_ENTRY(soundstream_class_entry, "SWFSoundStream", swfsoundstream_functions); + INIT_CLASS_ENTRY(filter_class_entry, "SWFFilter", swffilter_functions); + INIT_CLASS_ENTRY(filtermatrix_class_entry, "SWFFilterMatrix", swffiltermatrix_functions); + INIT_CLASS_ENTRY(shadow_class_entry, "SWFShadow", swfshadow_functions); + INIT_CLASS_ENTRY(blur_class_entry, "SWFBlur", swfblur_functions); + INIT_CLASS_ENTRY(cxform_class_entry, "SWFCXform", swfcxform_functions); + INIT_CLASS_ENTRY(matrix_class_entry, "SWFMatrix", swfmatrix_functions); + INIT_CLASS_ENTRY(input_class_entry, "SWFInput", swfinput_functions); + INIT_CLASS_ENTRY(browserfont_class_entry, "SWFBrowserFont", swfbrowserfont_functions); + INIT_CLASS_ENTRY(fontcollection_class_entry, "SWFFontCollection", swffontcollection_functions); #endif + INIT_CLASS_ENTRY(character_class_entry, "SWFCharacter", swfcharacter_functions); + shape_class_entry_ptr = zend_register_internal_class(&shape_class_entry TSRMLS_CC); fill_class_entry_ptr = zend_register_internal_class(&fill_class_entry TSRMLS_CC); @@ -4333,17 +6494,29 @@ PHP_MINIT_FUNCTION(ming) button_class_entry_ptr = zend_register_internal_class(&button_class_entry TSRMLS_CC); action_class_entry_ptr = zend_register_internal_class(&action_class_entry TSRMLS_CC); morph_class_entry_ptr = zend_register_internal_class(&morph_class_entry TSRMLS_CC); + movieclip_class_entry_ptr = zend_register_internal_class(&movieclip_class_entry TSRMLS_CC); sprite_class_entry_ptr = zend_register_internal_class(&sprite_class_entry TSRMLS_CC); sound_class_entry_ptr = zend_register_internal_class(&sound_class_entry TSRMLS_CC); #ifdef HAVE_NEW_MING fontchar_class_entry_ptr = zend_register_internal_class(&fontchar_class_entry TSRMLS_CC); + buttonrecord_class_entry_ptr = zend_register_internal_class(&buttonrecord_class_entry TSRMLS_CC); soundinstance_class_entry_ptr = zend_register_internal_class(&soundinstance_class_entry TSRMLS_CC); videostream_class_entry_ptr = zend_register_internal_class(&videostream_class_entry TSRMLS_CC); -#endif -#ifdef HAVE_SWFPREBUILTCLIP + binarydata_class_entry_ptr = zend_register_internal_class(&binarydata_class_entry TSRMLS_CC); + initaction_class_entry_ptr = zend_register_internal_class(&initaction_class_entry TSRMLS_CC); prebuiltclip_class_entry_ptr = zend_register_internal_class(&prebuiltclip_class_entry TSRMLS_CC); + soundstream_class_entry_ptr = zend_register_internal_class(&soundstream_class_entry TSRMLS_CC); + filter_class_entry_ptr = zend_register_internal_class(&filter_class_entry TSRMLS_CC); + filtermatrix_class_entry_ptr = zend_register_internal_class(&filtermatrix_class_entry TSRMLS_CC); + shadow_class_entry_ptr = zend_register_internal_class(&shadow_class_entry TSRMLS_CC); + blur_class_entry_ptr = zend_register_internal_class(&blur_class_entry TSRMLS_CC); + cxform_class_entry_ptr = zend_register_internal_class(&cxform_class_entry TSRMLS_CC); + matrix_class_entry_ptr = zend_register_internal_class(&matrix_class_entry TSRMLS_CC); + input_class_entry_ptr = zend_register_internal_class(&input_class_entry TSRMLS_CC); + browserfont_class_entry_ptr = zend_register_internal_class(&browserfont_class_entry TSRMLS_CC); + fontcollection_class_entry_ptr = zend_register_internal_class(&fontcollection_class_entry TSRMLS_CC); #endif - + character_class_entry_ptr = zend_register_internal_class(&character_class_entry TSRMLS_CC); return SUCCESS; } /* }}} */ diff -Naurp ming/php_ming.h ming.oden/php_ming.h --- ming/php_ming.h 2008-12-31 12:17:40.000000000 +0100 +++ ming.oden/php_ming.h 2011-10-26 08:33:18.000000000 +0200 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,11 +18,35 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ming.h,v 1.17.2.1.2.5 2008/12/31 11:17:40 sebastian Exp $ */ +/* $Id$ */ #ifndef _PHP_MING_H #define _PHP_MING_H +#if !defined(PHP_METHOD) +/* Must be building for PHP4 */ +#define ZEND_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_FN(classname##_##name)) +#define PHP_METHOD ZEND_METHOD + +#define ZEND_ME(classname, name, arg_info, flags) ZEND_FALIAS(name, classname##_##name, arg_info) +#define PHP_ME ZEND_ME + + +#undef INIT_CLASS_ENTRY +#define INIT_CLASS_ENTRY(class_container, class_name, functions) \ + { \ + char *p; \ + php4_fix_funcnames(class_name,functions); \ + class_container.name = strdup(class_name); \ + p = class_container.name;while(*p) {*p = tolower(*p);p++;} \ + class_container.name_length = sizeof(class_name) - 1; \ + class_container.builtin_functions = functions; \ + class_container.handle_function_call = NULL; \ + class_container.handle_property_get = NULL; \ + class_container.handle_property_set = NULL; \ + } +#endif + #if HAVE_MING extern zend_module_entry ming_module_entry; @@ -39,15 +63,42 @@ PHP_METHOD(swfbitmap, getHeight); PHP_METHOD(swfvideostream, init); PHP_METHOD(swfvideostream, setdimention); PHP_METHOD(swfvideostream, getnumframes); +PHP_METHOD(swfvideostream, hasaudio); +PHP_METHOD(swfvideostream, setFrameMode); +PHP_METHOD(swfvideostream, nextFrame); +PHP_METHOD(swfvideostream, seek); PHP_METHOD(swfprebuiltclip, init); +PHP_METHOD(swfbinarydata, init); + +PHP_METHOD(swfshadow, init); + +PHP_METHOD(swfblur, init); + +PHP_METHOD(swffiltermatrix, init); + +PHP_METHOD(swffilter, init); + +PHP_METHOD(swfbrowserfont, init); + +PHP_METHOD(swfinput, init); + +PHP_METHOD(swfcxform, init); +PHP_METHOD(swfcxform, setColorAdd); +PHP_METHOD(swfcxform, setColorMult); + PHP_METHOD(swffill, init); PHP_METHOD(swffill, moveTo); +PHP_METHOD(swffill, move); PHP_METHOD(swffill, scaleTo); +PHP_METHOD(swffill, scale); PHP_METHOD(swffill, rotateTo); +PHP_METHOD(swffill, rotate); PHP_METHOD(swffill, skewXTo); +PHP_METHOD(swffill, skewX); PHP_METHOD(swffill, skewYTo); +PHP_METHOD(swffill, skewY); PHP_METHOD(swfgradient, init); PHP_METHOD(swfgradient, addEntry); @@ -68,6 +119,17 @@ PHP_METHOD(swfshape, drawarc); PHP_METHOD(swfshape, drawcircle); PHP_METHOD(swfshape, drawcubic); PHP_METHOD(swfshape, drawcubicto); +PHP_METHOD(swfshape, end); +PHP_METHOD(swfshape, useVersion); +PHP_METHOD(swfshape, getVersion); +PHP_METHOD(swfshape, setRenderHintingFlags); +PHP_METHOD(swfshape, getPenX); +PHP_METHOD(swfshape, getPenY); +PHP_METHOD(swfshape, hideLine); +PHP_METHOD(swfshape, drawCharacterBounds); +PHP_METHOD(swfshape, setLine2); +PHP_METHOD(swfshape, setLine2Filled); +PHP_METHOD(swfshape, dumpOutline); /* SWFMovie */ @@ -79,9 +141,7 @@ PHP_METHOD(swfmovie, add); PHP_METHOD(swfmovie, remove); PHP_METHOD(swfmovie, nextFrame); PHP_METHOD(swfmovie, labelFrame); -#ifdef HAVE_SWFMOVIE_NAMEDANCHOR PHP_METHOD(swfmovie, namedAnchor); -#endif PHP_METHOD(swfmovie, setBackground); PHP_METHOD(swfmovie, setRate); PHP_METHOD(swfmovie, setDimension); @@ -97,6 +157,8 @@ PHP_METHOD(swfmovie, stopSound); PHP_METHOD(swfmovie, importChar); PHP_METHOD(swfmovie, importFont); PHP_METHOD(swfmovie, addFont); +PHP_METHOD(swfmovie, replace); +PHP_METHOD(swfmovie, getRate); # endif /* SWFSprint */ @@ -117,22 +179,22 @@ PHP_METHOD(swfsprite, stopSound); PHP_METHOD(swffont, init); PHP_METHOD(swffont, getWidth); - -#ifdef HAVE_NEW_MING -PHP_METHOD(swffont, getUTF8Width); -/*PHP_METHOD(swffont, getWideWidth);*/ -#endif - PHP_METHOD(swffont, getAscent); PHP_METHOD(swffont, getDescent); PHP_METHOD(swffont, getLeading); - #ifdef HAVE_NEW_MING -/*PHP_METHOD(swffont, addChars);*/ -PHP_METHOD(swffont, getShape); +PHP_METHOD(swffont, getUTF8Width); +PHP_METHOD(swffont, getGlyphCount); +PHP_METHOD(swffont, getName); #endif +PHP_METHOD(swffont, getShape); + +/* SWFFontCollection */ + +PHP_METHOD(swffontcollection, init); +PHP_METHOD(swffontcollection, getFont); +PHP_METHOD(swffontcollection, getFontCount); -PHP_METHOD(swffont, getLeading); /* SWFText */ @@ -175,8 +237,11 @@ PHP_METHOD(swftextfield, setLineSpacing) PHP_METHOD(swftextfield, setColor); PHP_METHOD(swftextfield, setName); PHP_METHOD(swftextfield, addString); +PHP_METHOD(swftextfield, addUTF8String); PHP_METHOD(swftextfield, setPadding); PHP_METHOD(swftextfield, addChars); +PHP_METHOD(swftextfield, setLength); +PHP_METHOD(swftextfield, setFieldHeight); /* SWFFontChar */ @@ -204,6 +269,8 @@ PHP_METHOD(swfdisplayitem, setName); PHP_METHOD(swfdisplayitem, addAction); #ifdef HAVE_NEW_MING +PHP_METHOD(swfdisplayitem, addFilter); +PHP_METHOD(swfdisplayitem, flush); PHP_METHOD(swfdisplayitem, remove); PHP_METHOD(swfdisplayitem, setMaskLevel); PHP_METHOD(swfdisplayitem, endMask); @@ -214,6 +281,7 @@ PHP_METHOD(swfdisplayitem, getYScale); PHP_METHOD(swfdisplayitem, getXSkew); PHP_METHOD(swfdisplayitem, getYSkew); PHP_METHOD(swfdisplayitem, getRot); +PHP_METHOD(swfdisplayitem, getDepth); #endif /* SWFButton */ @@ -234,11 +302,33 @@ PHP_METHOD(swfbutton, addAction); #ifdef HAVE_NEW_MING PHP_METHOD(swfbutton, addSound); +PHP_METHOD(swfbutton, addCharacter); #endif +/* SWFButtonRecord */ + +PHP_METHOD(swfbuttonrecord, setDepth); +PHP_METHOD(swfbuttonrecord, setBlendMode); +PHP_METHOD(swfbuttonrecord, move); +PHP_METHOD(swfbuttonrecord, moveTo); +PHP_METHOD(swfbuttonrecord, rotate); +PHP_METHOD(swfbuttonrecord, rotateTo); +PHP_METHOD(swfbuttonrecord, scale); +PHP_METHOD(swfbuttonrecord, scaleTo); +PHP_METHOD(swfbuttonrecord, skewX); +PHP_METHOD(swfbuttonrecord, skewXTo); +PHP_METHOD(swfbuttonrecord, skewY); +PHP_METHOD(swfbuttonrecord, skewYTo); +PHP_METHOD(swfbuttonrecord, addFilter); + /* SWFAction */ PHP_METHOD(swfaction, init); +PHP_METHOD(swfaction, compile); + +/* SWFInitAction */ + +PHP_METHOD(swfinitaction, init); /* SWFMorph */ @@ -268,8 +358,6 @@ PHP_FUNCTION(ming_useSWFVersion); #ifdef HAVE_NEW_MING PHP_FUNCTION(ming_useConstants); -#endif -#ifdef HAVE_MING_SETSWFCOMPRESSION PHP_FUNCTION(ming_setSWFCompression); #endif