1 /*
2 Ming, an SWF output library
3
4 Copyright (C) 2004-2011 Sandro Santilli <strk@keybit.net>
5 Copyright (C) 2006-2013 Stuart R. Anderson <anderson@netsweng.com>
6 Copyright (C) 2004-2008 Klaus Rechert <klaus@rechert.de>
7 Copyright (C) 2008 Frank M. Kromann <fmk@php.net>
8 Copyright (C) 2001-2002 Dave Hayden <dave@opaque.net>
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
24 */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include "php.h"
31 #include "php_globals.h"
32 #include "ext/standard/info.h"
33 #include "ext/standard/file.h"
34 #include "ext/standard/fsock.h"
35 #include "php_streams.h"
36
37 #if HAVE_MING
38
39 #include "php_ming.h"
40 #include <stdio.h>
41 #include <math.h>
42 #include <ming.h>
43
44 #ifndef HAVE_DESTROY_SWF_BLOCK
45 void destroySWFBlock(SWFBlock block);
46 #endif
47
48 static zend_function_entry ming_functions[] = {
49 PHP_FALIAS(ming_setcubicthreshold, ming_setCubicThreshold, NULL)
50 PHP_FALIAS(ming_setscale, ming_setScale, NULL)
51 PHP_FALIAS(ming_useswfversion, ming_useSWFVersion, NULL)
52 PHP_FALIAS(ming_keypress, ming_keypress, NULL)
53 #ifdef HAVE_NEW_MING
54 PHP_FALIAS(ming_useconstants, ming_useConstants, NULL)
55 PHP_FALIAS(ming_setswfcompression, ming_setSWFCompression, NULL)
56 #endif
57 { NULL, NULL, NULL }
58 };
59
60 static SWFMovie getMovie(zval *id TSRMLS_DC);
61 static SWFFill getFill(zval *id TSRMLS_DC);
62 static SWFGradient getGradient(zval *id TSRMLS_DC);
63 static SWFBitmap getBitmap(zval *id TSRMLS_DC);
64 static SWFShape getShape(zval *id TSRMLS_DC);
65 static SWFFont getFont(zval *id TSRMLS_DC);
66 static SWFText getText(zval *id TSRMLS_DC);
67 static SWFTextField getTextField(zval *id TSRMLS_DC);
68 static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC);
69 static SWFButton getButton(zval *id TSRMLS_DC);
70 static SWFAction getAction(zval *id TSRMLS_DC);
71 static SWFInitAction getInitAction(zval *id TSRMLS_DC);
72 static SWFMorph getMorph(zval *id TSRMLS_DC);
73 static SWFMovieClip getSprite(zval *id TSRMLS_DC);
74 static SWFSound getSound(zval *id TSRMLS_DC);
75 static SWFInput getInput(zval *id TSRMLS_DC);
76 #ifdef HAVE_NEW_MING
77 static SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC);
78 static SWFSoundInstance getSoundInstance(zval *id TSRMLS_DC);
79 static SWFVideoStream getVideoStream(zval *id TSRMLS_DC);
80 static SWFButtonRecord getButtonRecord(zval *id TSRMLS_DC);
81 static SWFPrebuiltClip getPrebuiltClip(zval *id TSRMLS_DC);
82 static SWFCharacter getCharacterClass(zval *id TSRMLS_DC);
83 static SWFBinaryData getBinaryData(zval *id TSRMLS_DC);
84 static SWFBlur getBlur(zval *id TSRMLS_DC);
85 static SWFShadow getShadow(zval *id TSRMLS_DC);
86 static SWFFilterMatrix getFilterMatrix(zval *id TSRMLS_DC);
87 static SWFFilter getFilter(zval *id TSRMLS_DC);
88 static SWFCXform getCXform(zval *id TSRMLS_DC);
89 static SWFMatrix getMatrix(zval *id TSRMLS_DC);
90 #endif
91
92 #if PHP_API_VERSION < 20100412
93 #define PHP_MING_FILE_CHK(file) \
94 if ((PG(safe_mode) && !php_checkuid((file), NULL, CHECKUID_CHECK_FILE_AND_DIR)) || php_check_open_basedir((file) TSRMLS_CC)) { \
95 RETURN_FALSE; \
96 }
97 #else
98 #define PHP_MING_FILE_CHK(file) \
99 if (php_check_open_basedir((file) TSRMLS_CC)) { \
100 RETURN_FALSE; \
101 }
102 #endif
103
104 #if PHP_VERSION_ID >= 70000
105 typedef size_t zend_strlen;
106 #else
107 typedef int zend_strlen;
108 typedef long zend_long;
109 #endif
110
111
112 /* {{{ proto void ming_setcubicthreshold (int threshold)
113 Set cubic threshold (?) */
PHP_FUNCTION(ming_setCubicThreshold)114 PHP_FUNCTION(ming_setCubicThreshold)
115 {
116 zend_long num;
117
118 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) {
119 return;
120 }
121 Ming_setCubicThreshold(num);
122 }
123 /* }}} */
124
125 /* {{{ proto void ming_setscale(float scale)
126 Set scale (?) */
PHP_FUNCTION(ming_setScale)127 PHP_FUNCTION(ming_setScale)
128 {
129 double num;
130
131 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) {
132 return;
133 }
134 Ming_setScale((float)num);
135 }
136 /* }}} */
137
138 /* {{{ proto void ming_useswfversion(int version)
139 Use SWF version (?) */
PHP_FUNCTION(ming_useSWFVersion)140 PHP_FUNCTION(ming_useSWFVersion)
141 {
142 zend_long num;
143
144 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) {
145 return;
146 }
147 Ming_useSWFVersion(num);
148 }
149 /* }}} */
150
151 #ifdef HAVE_NEW_MING
152 /* {{{ proto void ming_useconstants(int use)
153 Use constant pool (?) */
PHP_FUNCTION(ming_useConstants)154 PHP_FUNCTION(ming_useConstants)
155 {
156 zend_long num;
157
158 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) {
159 return;
160 }
161 Ming_useConstants(num);
162 }
163 /* }}} */
164
165 /* {{{ set output compression */
PHP_FUNCTION(ming_setSWFCompression)166 PHP_FUNCTION(ming_setSWFCompression)
167 {
168 zend_long num;
169
170 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) {
171 return;
172 }
173 Ming_setSWFCompression(num);
174 }
175 /* }}} */
176
177 #endif
178
179 static int le_swfmoviep;
180 static int le_swfshapep;
181 static int le_swffillp;
182 static int le_swfgradientp;
183 static int le_swfbitmapp;
184 static int le_swffontp;
185 static int le_swftextp;
186 static int le_swftextfieldp;
187 static int le_swfdisplayitemp;
188 static int le_swfbuttonp;
189 static int le_swfactionp;
190 static int le_swfmorphp;
191 static int le_swfmovieclipp;
192 static int le_swfspritep;
193 static int le_swfinputp;
194 static int le_swfsoundp;
195 #ifdef HAVE_NEW_MING
196 static int le_swffontcharp;
197 static int le_swfsoundinstancep;
198 static int le_swfvideostreamp;
199 static int le_swfbuttonrecordp;
200 static int le_swfbinarydatap;
201 static int le_swfinitactionp;
202 static int le_swfprebuiltclipp;
203 static int le_swfsoundstreamp;
204 static int le_swffilterp;
205 static int le_swfblurp;
206 static int le_swfshadowp;
207 static int le_swffiltermatrixp;
208 static int le_swfcxformp;
209 static int le_swfmatrixp;
210 static int le_swfbrowserfontp;
211 static int le_swffontcollectionp;
212 #endif
213 static int le_swfcharacterp;
214
215 static zend_class_entry *movie_class_entry_ptr;
216 static zend_class_entry *shape_class_entry_ptr;
217 static zend_class_entry *fill_class_entry_ptr;
218 static zend_class_entry *gradient_class_entry_ptr;
219 static zend_class_entry *bitmap_class_entry_ptr;
220 static zend_class_entry *font_class_entry_ptr;
221 static zend_class_entry *text_class_entry_ptr;
222 static zend_class_entry *textfield_class_entry_ptr;
223 static zend_class_entry *displayitem_class_entry_ptr;
224 static zend_class_entry *button_class_entry_ptr;
225 static zend_class_entry *action_class_entry_ptr;
226 static zend_class_entry *morph_class_entry_ptr;
227 static zend_class_entry *movieclip_class_entry_ptr;
228 static zend_class_entry *sprite_class_entry_ptr;
229 static zend_class_entry *sound_class_entry_ptr;
230 static zend_class_entry *character_class_entry_ptr;
231 static zend_class_entry *input_class_entry_ptr;
232 #ifdef HAVE_NEW_MING
233 static zend_class_entry *fontchar_class_entry_ptr;
234 static zend_class_entry *soundinstance_class_entry_ptr;
235 static zend_class_entry *videostream_class_entry_ptr;
236 static zend_class_entry *buttonrecord_class_entry_ptr;
237 static zend_class_entry *binarydata_class_entry_ptr;
238 static zend_class_entry *initaction_class_entry_ptr;
239 static zend_class_entry *prebuiltclip_class_entry_ptr;
240 static zend_class_entry *soundstream_class_entry_ptr;
241 static zend_class_entry *filter_class_entry_ptr;
242 static zend_class_entry *blur_class_entry_ptr;
243 static zend_class_entry *shadow_class_entry_ptr;
244 static zend_class_entry *filtermatrix_class_entry_ptr;
245 static zend_class_entry *cxform_class_entry_ptr;
246 static zend_class_entry *matrix_class_entry_ptr;
247 static zend_class_entry *browserfont_class_entry_ptr;
248 static zend_class_entry *fontcollection_class_entry_ptr;
249 #endif
250 static zend_class_entry *character_class_entry_ptr;
251
252 /* {{{ internal function SWFgetProperty
253 */
254 #if PHP_VERSION_ID >= 70000
SWFgetProperty(zval * id,char * name,int namelen,int proptype)255 static void *SWFgetProperty(zval *id, char *name, int namelen, int proptype)
256 {
257 zval *tmp;
258 #else
259 static void *SWFgetProperty(zval *id, char *name, int namelen, int proptype TSRMLS_DC)
260 {
261 zval **tmp;
262 int id_to_find;
263 void *property;
264 int type;
265 #endif
266
267 if (id) {
268 #if PHP_VERSION_ID >= 70000
269 if ((tmp = zend_hash_str_find(Z_OBJPROP_P(id), name, namelen)) != NULL) {
270 return zend_fetch_resource_ex(tmp, name, proptype);
271 } else {
272 /* php_error_docref(NULL, E_WARNING, "Unable to find property %s", name); */
273 return NULL;
274 }
275 #else
276 if (zend_hash_find(Z_OBJPROP_P(id), name, namelen+1, (void **)&tmp) == FAILURE) {
277 /* php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find property %s", name); */
278 return NULL;
279 }
280 id_to_find = Z_LVAL_PP(tmp);
281 property = zend_list_find(id_to_find, &type);
282
283 if (!property || type != proptype) {
284 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find identifier (%d)", id_to_find);
285 return NULL;
286 }
287 return property;
288 #endif
289 } else {
290 return NULL;
291 }
292 }
293 /* }}} */
294
295 /* {{{ SWFCharacter
296 */
297
298 /* {{{ internal function SWFCharacter getCharacter(zval *id)
299 Returns the SWFCharacter contained in zval *id */
300 static SWFCharacter getCharacter(zval *id TSRMLS_DC)
301 {
302 if (ZVAL_IS_NULL(id)) {
303 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Parameter is null");
304 return NULL;
305 }
306
307 if (Z_TYPE_P(id) != IS_OBJECT) {
308 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Parameter is not an object");
309 return NULL;
310 }
311
312 if (Z_OBJCE_P(id) == shape_class_entry_ptr)
313 return (SWFCharacter)getShape(id TSRMLS_CC);
314 else if (Z_OBJCE_P(id) == font_class_entry_ptr)
315 return (SWFCharacter)getFont(id TSRMLS_CC);
316 else if (Z_OBJCE_P(id) == text_class_entry_ptr)
317 return (SWFCharacter)getText(id TSRMLS_CC);
318 else if (Z_OBJCE_P(id) == textfield_class_entry_ptr)
319 return (SWFCharacter)getTextField(id TSRMLS_CC);
320 else if (Z_OBJCE_P(id) == button_class_entry_ptr)
321 return (SWFCharacter)getButton(id TSRMLS_CC);
322 else if (Z_OBJCE_P(id) == morph_class_entry_ptr)
323 return (SWFCharacter)getMorph(id TSRMLS_CC);
324 else if (Z_OBJCE_P(id) == movieclip_class_entry_ptr)
325 return (SWFCharacter)getSprite(id TSRMLS_CC);
326 else if (Z_OBJCE_P(id) == sprite_class_entry_ptr)
327 return (SWFCharacter)getSprite(id TSRMLS_CC);
328 else if (Z_OBJCE_P(id) == bitmap_class_entry_ptr)
329 return (SWFCharacter)getBitmap(id TSRMLS_CC);
330 else if(Z_OBJCE_P(id) == sound_class_entry_ptr)
331 return (SWFCharacter)getSound(id TSRMLS_CC);
332 #ifdef HAVE_NEW_MING
333 else if(Z_OBJCE_P(id) == fontchar_class_entry_ptr)
334 return (SWFCharacter)getFontCharacter(id TSRMLS_CC);
335 else if(Z_OBJCE_P(id) == soundinstance_class_entry_ptr)
336 return (SWFCharacter)getSoundInstance(id TSRMLS_CC);
337 else if(Z_OBJCE_P(id) == videostream_class_entry_ptr)
338 return (SWFCharacter)getVideoStream(id TSRMLS_CC);
339 else if(Z_OBJCE_P(id) == buttonrecord_class_entry_ptr)
340 return (SWFCharacter)getButtonRecord(id TSRMLS_CC);
341 else if(Z_OBJCE_P(id) == prebuiltclip_class_entry_ptr)
342 return (SWFCharacter)getPrebuiltClip(id TSRMLS_CC);
343 #endif
344 else
345 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCharacter");
346 return NULL;
347 }
348 /* }}} */
349
350 static SWFCharacter getCharacterClass(zval *id TSRMLS_DC)
351 {
352 void *character = SWFgetProperty(id, "character", strlen("character"), le_swfcharacterp TSRMLS_CC);
353
354 if (!character) {
355 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCharacter");
356 }
357 return (SWFCharacter)character;
358 }
359
360 /* {{{ proto swfcharacter::getWidth() */
361 PHP_METHOD(swfcharacter, getWidth)
362 {
363 RETURN_DOUBLE(SWFCharacter_getWidth(getCharacter(getThis() TSRMLS_CC)));
364 }
365 /* }}} */
366
367 /* {{{ proto swfcharacter::getHeight() */
368 PHP_METHOD(swfcharacter, getHeight)
369 {
370 RETURN_DOUBLE(SWFCharacter_getHeight(getCharacter(getThis() TSRMLS_CC)));
371 }
372 /* }}} */
373
374 static zend_function_entry swfcharacter_functions[] = {
375 PHP_ME(swfcharacter, getWidth, NULL, 0)
376 PHP_ME(swfcharacter, getHeight, NULL, 0)
377 { NULL, NULL, NULL }
378 };
379
380 /* }}} */
381
382 #if PHP_VERSION_ID >= 70000
383 static void destroy_SWFInput_resource(zend_resource *resource)
384 #else
385 static void destroy_SWFInput_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
386 #endif
387 {
388 destroySWFInput((SWFInput)resource->ptr);
389 }
390
391 /* {{{ getInput_fromFileResource - utility func for making an SWFInput from an fopened resource */
392 static SWFInput getInput_fromFileResource(zval *zfile TSRMLS_DC)
393 {
394 FILE *file;
395 php_stream *stream;
396 SWFInput input;
397
398 #if PHP_VERSION_ID >= 70000
399 php_stream_from_zval_no_verify(stream, zfile);
400 #else
401 php_stream_from_zval_no_verify(stream, &zfile);
402 #endif
403
404 if (stream == NULL) {
405 return NULL;
406 }
407
408 if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void *) &file, REPORT_ERRORS) != SUCCESS) {
409 return NULL;
410 }
411
412 input = newSWFInput_file(file);
413 #if PHP_VERSION_ID >= 70000
414 Z_ADDREF_P(zfile);
415 zend_register_resource(input, le_swfinputp);
416 #else
417 zend_list_addref(Z_LVAL_P(zfile));
418 zend_list_addref(zend_list_insert(input, le_swfinputp));
419 #endif
420 return input;
421 }
422 /* }}} */
423
424 /* {{{ internal function isInput */
425 static int isInput(zval *id TSRMLS_DC)
426 {
427 void *in = SWFgetProperty(id, "input", strlen("input"), le_swfinputp TSRMLS_CC);
428
429 return (in != 0);
430 }
431 /* }}} */
432
433 /* {{{ internal function getInput */
434 static SWFInput getInput(zval *id TSRMLS_DC)
435 {
436 void *in = SWFgetProperty(id, "input", strlen("input"), le_swfinputp TSRMLS_CC);
437
438 if (!in) {
439 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFInput");
440 }
441 return (SWFInput)in;
442 }
443 /* }}} */
444
445 /* {{{ proto void swfinput::__construct(string data) */
446 PHP_METHOD(swfinput, __construct)
447 {
448 SWFInput input;
449 char *data;
450 zend_strlen data_len;
451 #if PHP_VERSION_ID >= 70000
452 zend_resource *ret;
453 #else
454 int ret;
455 #endif
456
457 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) {
458 return;
459 }
460
461 input = newSWFInput_bufferCopy((unsigned char *)data, data_len);
462
463 #if PHP_VERSION_ID >= 70000
464 ret = zend_register_resource(input, le_swfinputp);
465 add_property_resource(getThis(), "input", ret);
466 #else
467 object_init_ex(getThis(), input_class_entry_ptr);
468 ret = zend_list_insert(input, le_swfinputp);
469 add_property_resource(getThis(), "input", ret);
470 zend_list_addref(ret);
471 #endif
472 }
473
474 static zend_function_entry swfinput_functions[] = {
475 PHP_ME(swfinput, __construct, NULL, 0)
476 { NULL, NULL, NULL }
477 };
478 /* }}} */
479
480 /* {{{ SWFFontCollection */
481 static SWFFontCollection getFontCollection(zval *id TSRMLS_DC)
482 {
483 void *fc = SWFgetProperty(id, "fontcollection", strlen("fontcollection"),
484 le_swffontcollectionp TSRMLS_CC);
485
486 if (!fc) {
487 php_error_docref(NULL TSRMLS_CC, E_ERROR,
488 "Called object is not an SWFFontCollection");
489 }
490 return (SWFFontCollection)fc;
491 }
492
493 /* {{{ proto swffontcollection::init(filename) */
494 PHP_METHOD(swffontcollection, __construct)
495 {
496 char *filename;
497 zend_strlen filename_len;
498 #if PHP_VERSION_ID >= 70000
499 zend_resource *ret;
500 #else
501 int ret;
502 #endif
503 SWFFontCollection fc;
504
505 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
506 return;
507 }
508
509 fc = newSWFFontCollection_fromFile(filename);
510 if(fc) {
511 #if PHP_VERSION_ID >= 70000
512 ret = zend_register_resource(fc, le_swffontcollectionp);
513 add_property_resource(getThis(), "fontcollection", ret);
514 #else
515 object_init_ex(getThis(), fontcollection_class_entry_ptr);
516 ret = zend_list_insert(fc, le_swffontcollectionp);
517 add_property_resource(getThis(), "fontcollection", ret);
518 zend_list_addref(ret);
519 #endif
520 }
521 }
522 /* }}} */
523
524 /* {{{ proto long swffontcollection::getFontCount() */
525 PHP_METHOD(swffontcollection, getFontCount)
526 {
527 RETURN_LONG(SWFFontCollection_getFontCount(
528 getFontCollection(getThis() TSRMLS_CC)));
529 }
530 /* }}} */
531
532 /* {{{ proto SWFFont swffontcollection::getFont(int index) */
533 PHP_METHOD(swffontcollection, getFont)
534 {
535 zend_long index;
536 #if PHP_VERSION_ID >= 70000
537 zend_resource * ret;
538 #else
539 int ret;
540 #endif
541 SWFFont font;
542
543 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) {
544 return;
545 }
546
547 font = SWFFontCollection_getFont(getFontCollection(getThis() TSRMLS_CC), index);
548
549 if(font != NULL) {
550 object_init_ex(return_value, font_class_entry_ptr);
551 #if PHP_VERSION_ID >= 70000
552 ret = zend_register_resource(font, le_swffontp);
553 add_property_resource(return_value, "font", ret);
554 ret->gc.refcount++;
555 #else
556 ret = zend_list_insert(font, le_swffontp);
557 add_property_resource(return_value, "font", ret);
558 zend_list_addref(ret);
559 #endif
560 }
561 }
562 /* }}} */
563
564 #if PHP_VERSION_ID >= 70000
565 static void destroy_SWFFontCollection_resource(zend_resource *resource)
566 #else
567 static void destroy_SWFFontCollection_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
568 #endif
569 {
570 destroySWFFontCollection((SWFFontCollection)resource->ptr);
571 }
572
573 static zend_function_entry swffontcollection_functions[] = {
574 PHP_ME(swffontcollection, __construct, NULL, 0)
575 PHP_ME(swffontcollection, getFont, NULL, 0)
576 PHP_ME(swffontcollection, getFontCount, NULL, 0)
577 { NULL, NULL, NULL }
578 };
579 /* }}} */
580
581 /* {{{ SWFBrowserFont */
582 static SWFBrowserFont getBrowserFont(zval *id TSRMLS_DC)
583 {
584 void *bf = SWFgetProperty(id, "browserfont", strlen("browserfont"),
585 le_swfbrowserfontp TSRMLS_CC);
586
587 if (!bf) {
588 php_error_docref(NULL TSRMLS_CC, E_ERROR,
589 "Called object is not an SWFBrowserFont");
590 }
591 return (SWFBrowserFont)bf;
592 }
593
594 /* {{{ proto swfbrowserfont::_construct(fontname) */
595 PHP_METHOD(swfbrowserfont, __construct)
596 {
597 char *name;
598 zend_strlen name_len;
599 #if PHP_VERSION_ID >= 70000
600 zend_resource *ret;
601 #else
602 int ret;
603 #endif
604 SWFBrowserFont font;
605
606 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
607 return;
608 }
609
610 font = newSWFBrowserFont(name);
611 if(font) {
612 #if PHP_VERSION_ID >= 70000
613 ret = zend_register_resource(font, le_swfbrowserfontp);
614 add_property_resource(getThis(), "browserfont", ret);
615 #else
616 object_init_ex(getThis(), browserfont_class_entry_ptr);
617 ret = zend_list_insert(font, le_swfbrowserfontp);
618 add_property_resource(getThis(), "browserfont", ret);
619 zend_list_addref(ret);
620 #endif
621 }
622 }
623 /* }}} */
624
625 #if PHP_VERSION_ID >= 70000
626 static void destroy_SWFBrowserFont_resource(zend_resource *resource)
627 #else
628 static void destroy_SWFBrowserFont_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
629 #endif
630 {
631 destroySWFBrowserFont((SWFBrowserFont)resource->ptr);
632 }
633
634 static zend_function_entry swfbrowserfont_functions[] = {
635 PHP_ME(swfbrowserfont, __construct, NULL, 0)
636 { NULL, NULL, NULL }
637 };
638 /* }}} */
639
640 /* {{{ SWFCXform
641 */
642 /* {{{ proto void swfcxform::__construct([rAdd, gAdd, bAdd, aAdd, rMult, gMult, bMult, aMult]) */
643 PHP_METHOD(swfcxform, __construct)
644 {
645 SWFCXform cx;
646 zend_long rAdd, gAdd, bAdd, aAdd;
647 double rMult, gMult, bMult, aMult;
648 #if PHP_VERSION_ID >= 70000
649 zend_resource *ret;
650 #else
651 int ret;
652 #endif
653
654 switch(ZEND_NUM_ARGS())
655 {
656 case 0:
657 cx = newSWFCXform(0, 0, 0, 0, 1.0, 1.0, 1.0, 1.0);
658 break;
659 case 8:
660 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllldddd",
661 &rAdd, &gAdd, &bAdd, &aAdd,
662 &rMult, &gMult, &bMult, &aMult) == FAILURE) {
663 return;
664 }
665 cx = newSWFCXform(rAdd, gAdd, bAdd, aAdd, rMult, gMult, bMult, aMult);
666 break;
667 default:
668 WRONG_PARAM_COUNT;
669 }
670
671 #if PHP_VERSION_ID >= 70000
672 ret = zend_register_resource(cx, le_swfcxformp);
673 add_property_resource(getThis(), "cx", ret);
674 #else
675 object_init_ex(getThis(), cxform_class_entry_ptr);
676 ret = zend_list_insert(cx, le_swfcxformp);
677 add_property_resource(getThis(), "cx", ret);
678 zend_list_addref(ret);
679 #endif
680 }
681 /* }}} */
682
683 /* {{{ proto void setColorAdd(r, g, b, a) */
684 PHP_METHOD(swfcxform, setColorAdd)
685 {
686 zend_long rAdd, gAdd, bAdd, aAdd;
687
688 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &rAdd, &gAdd, &bAdd, &aAdd) == FAILURE) {
689 return;
690 }
691
692 SWFCXform_setColorAdd(getCXform(getThis() TSRMLS_CC), rAdd, gAdd, bAdd, aAdd);
693 }
694 /* }}} */
695
696 /* {{{ proto void setColorMult(r, g, b, a) */
697 PHP_METHOD(swfcxform, setColorMult)
698 {
699 double rMult, gMult, bMult, aMult;
700
701 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &rMult, &gMult, &bMult, &aMult) == FAILURE) {
702 return;
703 }
704
705 SWFCXform_setColorMult(getCXform(getThis() TSRMLS_CC), rMult, gMult, bMult, aMult);
706 }
707 /* }}} */
708
709 #if PHP_VERSION_ID >= 70000
710 static void destroy_SWFCXform_resource(zend_resource *resource)
711 #else
712 static void destroy_SWFCXform_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
713 #endif
714 {
715 destroySWFCXform((SWFCXform)resource->ptr);
716 }
717
718 /* {{{ internal function getCXform */
719 static SWFCXform getCXform(zval *id TSRMLS_DC)
720 {
721 void *cx = SWFgetProperty(id, "cx", strlen("cx"), le_swfcxformp TSRMLS_CC);
722
723 if (!cx) {
724 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCXform");
725 }
726 return (SWFCXform)cx;
727 }
728 /* }}} */
729
730 static zend_function_entry swfcxform_functions[] = {
731 PHP_ME(swfcxform, __construct, NULL, 0)
732 PHP_ME(swfcxform, setColorAdd, NULL, 0)
733 PHP_ME(swfcxform, setColorMult, NULL, 0)
734 { NULL, NULL, NULL }
735 };
736 /* }}} */
737
738 /* {{{ SWFMatrix */
739
740 static SWFMatrix getMatrix(zval *id TSRMLS_DC)
741 {
742 void *matrix = SWFgetProperty(id, "matrix", strlen("matrix"), le_swfmatrixp TSRMLS_CC);
743
744 if(!matrix)
745 {
746 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMatrix");
747 }
748 return (SWFMatrix)matrix;
749 }
750
751 /* {{{ proto double swfmatrix::getScaleX */
752 PHP_METHOD(swfmatrix, getScaleX)
753 {
754 if (ZEND_NUM_ARGS() != 0) {
755 WRONG_PARAM_COUNT;
756 }
757 RETURN_DOUBLE(SWFMatrix_getScaleX(getMatrix(getThis() TSRMLS_CC)));
758 }
759 /* }}} */
760
761 /* {{{ proto double swfmatrix::getScaleX */
762 PHP_METHOD(swfmatrix, getScaleY)
763 {
764 if (ZEND_NUM_ARGS() != 0) {
765 WRONG_PARAM_COUNT;
766 }
767 RETURN_DOUBLE(SWFMatrix_getScaleY(getMatrix(getThis() TSRMLS_CC)));
768 }
769 /* }}} */
770
771 /* {{{ proto double swfmatrix::getRotate0 */
772 PHP_METHOD(swfmatrix, getRotate0)
773 {
774 if (ZEND_NUM_ARGS() != 0) {
775 WRONG_PARAM_COUNT;
776 }
777 RETURN_DOUBLE(SWFMatrix_getRotate0(getMatrix(getThis() TSRMLS_CC)));
778 }
779 /* }}} */
780
781 /* {{{ proto double swfmatrix::getRotate0 */
782 PHP_METHOD(swfmatrix, getRotate1)
783 {
784 if (ZEND_NUM_ARGS() != 0) {
785 WRONG_PARAM_COUNT;
786 }
787 RETURN_DOUBLE(SWFMatrix_getRotate1(getMatrix(getThis() TSRMLS_CC)));
788 }
789 /* }}} */
790
791 /* {{{ proto double swfmatrix::getTranslateX */
792 PHP_METHOD(swfmatrix, getTranslateX)
793 {
794 if (ZEND_NUM_ARGS() != 0) {
795 WRONG_PARAM_COUNT;
796 }
797 RETURN_DOUBLE(SWFMatrix_getTranslateX(getMatrix(getThis() TSRMLS_CC)));
798 }
799 /* }}} */
800
801 /* {{{ proto double swfmatrix::getTranslateY */
802 PHP_METHOD(swfmatrix, getTranslateY)
803 {
804 if (ZEND_NUM_ARGS() != 0) {
805 WRONG_PARAM_COUNT;
806 }
807 RETURN_DOUBLE(SWFMatrix_getTranslateY(getMatrix(getThis() TSRMLS_CC)));
808 }
809 /* }}} */
810
811 static zend_function_entry swfmatrix_functions[] = {
812 PHP_ME(swfmatrix, getScaleX, NULL, 0)
813 PHP_ME(swfmatrix, getScaleY, NULL, 0)
814 PHP_ME(swfmatrix, getRotate0, NULL, 0)
815 PHP_ME(swfmatrix, getRotate1, NULL, 0)
816 PHP_ME(swfmatrix, getTranslateX, NULL, 0)
817 PHP_ME(swfmatrix, getTranslateY, NULL, 0)
818 {NULL, NULL, NULL}
819 };
820 /* }}} */
821
822 /* {{{ SWFInitAction
823 */
824 /* {{{ proto void swfinitaction::__construct(action,[id])
825 Creates a new SWFInitAction object. */
826 PHP_METHOD(swfinitaction, __construct)
827 {
828 SWFInitAction init;
829 zval *zaction;
830 zend_long id = -1;
831 #if PHP_VERSION_ID >= 70000
832 zend_resource *ret;
833
834 if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|l", &zaction, &id) == FAILURE) {
835 return;
836 }
837
838 if (id==-1) {
839 init = newSWFInitAction(getAction(zaction));
840 } else {
841 init = newSWFInitAction_withId(getAction(zaction), id);
842 }
843
844 ret = zend_register_resource(init, le_swfinitactionp);
845 add_property_resource(getThis(), "initaction", ret);
846 #else
847 int ret;
848
849 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &zaction, &id) == FAILURE) {
850 return;
851 }
852
853 if (id==-1) {
854 init = newSWFInitAction(getAction(zaction TSRMLS_CC));
855 } else {
856 init = newSWFInitAction_withId(getAction(zaction TSRMLS_CC), id);
857 }
858
859 ret = zend_list_insert(init, le_swfinitactionp);
860 object_init_ex(getThis(), initaction_class_entry_ptr);
861 add_property_resource(getThis(), "initaction", ret);
862 zend_list_addref(ret);
863 #endif
864 }
865 /* no destructor for SWFInitAction, it's not a character */
866 /* }}} */
867
868 /* {{{ internal function getInitAction
869 Returns the SWFInitAction object contained in zval *id */
870 static inline SWFInitAction getInitAction(zval *id TSRMLS_DC)
871 {
872 void *action = SWFgetProperty(id, "initaction",
873 strlen("initaction"), le_swfinitactionp TSRMLS_CC);
874
875 if (!action) {
876 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFInitAction");
877 }
878 return (SWFInitAction)action;
879 }
880 /* }}} */
881
882 static zend_function_entry swfinitaction_functions[] = {
883 PHP_ME(swfinitaction, __construct, NULL, 0)
884 { NULL, NULL, NULL }
885 };
886 /* }}} */
887
888 /* {{{ SWFAction
889 */
890 /* {{{ proto void swfaction::__construct(string)
891 Creates a new SWFAction object, compiling the given script */
892 PHP_METHOD(swfaction, __construct)
893 {
894 SWFAction action;
895 char *script;
896 zend_strlen script_len;
897 #if PHP_VERSION_ID >= 70000
898 zend_resource *ret;
899 #else
900 int ret;
901 #endif
902
903 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &script, &script_len) == FAILURE) {
904 return;
905 }
906
907 action = newSWFAction(script);
908
909 if (!action) {
910 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Couldn't compile actionscript");
911 }
912
913 #if PHP_VERSION_ID >= 70000
914 ret = zend_register_resource(action, le_swfactionp);
915 add_property_resource(getThis(), "action", ret);
916 #else
917 ret = zend_list_insert(action, le_swfactionp);
918
919 object_init_ex(getThis(), action_class_entry_ptr);
920 add_property_resource(getThis(), "action", ret);
921 zend_list_addref(ret);
922 #endif
923 }
924 /* no destructor for SWFAction, it's not a character */
925 /* }}} */
926
927 /* {{{ proto long swfaction::compile(version) */
928 PHP_METHOD(swfaction, compile)
929 {
930 zend_long version;
931 int len, ret;
932
933 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &version) == FAILURE) {
934 return;
935 }
936
937 ret = SWFAction_compile(getAction(getThis() TSRMLS_CC), version, &len);
938
939 if (ret != 0) {
940 RETURN_LONG(-1);
941 }
942 else {
943 RETURN_LONG(len);
944 }
945 }
946 /* }}} */
947
948 /* {{{ internal function getAction
949 Returns the SWFAction object contained in zval *id */
950 static SWFAction getAction(zval *id TSRMLS_DC)
951 {
952 void *action = SWFgetProperty(id, "action", 6, le_swfactionp TSRMLS_CC);
953
954 if (!action) {
955 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFAction");
956 }
957 return (SWFAction)action;
958 }
959 /* }}} */
960
961 static zend_function_entry swfaction_functions[] = {
962 PHP_ME(swfaction, __construct, NULL, 0)
963 PHP_ME(swfaction, compile, NULL, 0)
964 { NULL, NULL, NULL }
965 };
966 /* }}} */
967
968 /* {{{ SWFBitmap
969 */
970 /* {{{ proto void swfbitmap::__construct(filename or SWFInput [, maskfilename / SWFInput])
971 Creates a new SWFBitmap object from jpg (with optional mask) or dbl file */
972 PHP_METHOD(swfbitmap, __construct)
973 {
974 zval *zfile, *zmask = NULL;
975 SWFBitmap bitmap;
976 SWFJpegWithAlpha bitmap_alpha;
977 SWFInput input = NULL, maskinput = NULL;
978 #if PHP_VERSION_ID >= 70000
979 zend_resource *ret;
980 #else
981 int ret;
982 #endif
983
984 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &zfile, &zmask) == FAILURE) {
985 return;
986 }
987
988 switch(Z_TYPE_P(zfile))
989 {
990 case IS_RESOURCE:
991 input = getInput_fromFileResource(zfile TSRMLS_CC);
992 break;
993 case IS_OBJECT:
994 input = getInput(zfile TSRMLS_CC);
995 break;
996 case IS_STRING:
997 input = newSWFInput_filename(Z_STRVAL_P(zfile));
998 if(input == NULL)
999 php_error(E_ERROR, "opening bitmap file failed");
1000 #if PHP_VERSION_ID >= 70000
1001 zend_register_resource(input, le_swfinputp);
1002 #else
1003 zend_list_addref(zend_list_insert(input, le_swfinputp));
1004 #endif
1005 break;
1006
1007 default:
1008 php_error(E_ERROR, "swfbitmap::__construct: need either a filename, "
1009 "a file ressource or SWFInput buffer.");
1010 }
1011
1012 if (zmask != NULL) {
1013 switch(Z_TYPE_P(zmask))
1014 {
1015 case IS_RESOURCE:
1016 maskinput = getInput_fromFileResource(zmask TSRMLS_CC);
1017 break;
1018 case IS_OBJECT:
1019 maskinput = getInput(zmask TSRMLS_CC);
1020 break;
1021 case IS_STRING:
1022 maskinput = newSWFInput_filename(Z_STRVAL_P(zmask));
1023 if(maskinput == NULL)
1024 php_error(E_ERROR, "opening mask file failed");
1025 #if PHP_VERSION_ID >= 70000
1026 zend_register_resource(maskinput, le_swfinputp);
1027 #else
1028 zend_list_addref(zend_list_insert(maskinput, le_swfinputp));
1029 #endif
1030 break;
1031
1032 default:
1033 php_error(E_ERROR, "swfbitmap::__construct: need either a filename, "
1034 "a file ressource or SWFInput buffer.");
1035 }
1036
1037 /* XX: this is very optimistic! is it really a JPEG ?!? */
1038 bitmap_alpha = newSWFJpegWithAlpha_fromInput(input, maskinput);
1039 if(bitmap_alpha) {
1040 #if PHP_VERSION_ID >= 70000
1041 ret = zend_register_resource(bitmap_alpha, le_swfbitmapp);
1042 add_property_resource(getThis(), "bitmap", ret);
1043 #else
1044 object_init_ex(getThis(), bitmap_class_entry_ptr);
1045 ret = zend_list_insert(bitmap_alpha, le_swfbitmapp);
1046 add_property_resource(getThis(), "bitmap", ret);
1047 zend_list_addref(ret);
1048 #endif
1049 }
1050 } else {
1051 bitmap = newSWFBitmap_fromInput(input);
1052 if(bitmap) {
1053 #if PHP_VERSION_ID >= 70000
1054 ret = zend_register_resource(bitmap, le_swfbitmapp);
1055 add_property_resource(getThis(), "bitmap", ret);
1056 #else
1057 object_init_ex(getThis(), bitmap_class_entry_ptr);
1058 ret = zend_list_insert(bitmap, le_swfbitmapp);
1059 add_property_resource(getThis(), "bitmap", ret);
1060 zend_list_addref(ret);
1061 #endif
1062 }
1063 }
1064 }
1065
1066 #if PHP_VERSION_ID >= 70000
1067 static void destroy_SWFBitmap_resource(zend_resource *resource)
1068 #else
1069 static void destroy_SWFBitmap_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
1070 #endif
1071 {
1072 destroySWFBitmap((SWFBitmap)resource->ptr);
1073 }
1074 /* }}} */
1075
1076 /* {{{ internal function getBitmap
1077 Returns the SWFBitmap object contained in zval *id */
1078 static SWFBitmap getBitmap(zval *id TSRMLS_DC)
1079 {
1080 void *bitmap = SWFgetProperty(id, "bitmap", 6, le_swfbitmapp TSRMLS_CC);
1081
1082 if (!bitmap) {
1083 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFBitmap");
1084 }
1085 return (SWFBitmap)bitmap;
1086 }
1087 /* }}} */
1088
1089 /* {{{ proto float swfbitmap::getWidth()
1090 Returns the width of this bitmap */
1091 PHP_METHOD(swfbitmap, getWidth)
1092 {
1093 if (ZEND_NUM_ARGS() != 0) {
1094 WRONG_PARAM_COUNT;
1095 }
1096 RETURN_DOUBLE(SWFBitmap_getWidth(getBitmap(getThis() TSRMLS_CC)));
1097 }
1098 /* }}} */
1099
1100 /* {{{ proto float swfbitmap::getHeight()
1101 Returns the height of this bitmap */
1102 PHP_METHOD(swfbitmap, getHeight)
1103 {
1104 if (ZEND_NUM_ARGS() != 0) {
1105 WRONG_PARAM_COUNT;
1106 }
1107 RETURN_DOUBLE(SWFBitmap_getHeight(getBitmap(getThis() TSRMLS_CC)));
1108 }
1109 /* }}} */
1110
1111 static zend_function_entry swfbitmap_functions[] = {
1112 PHP_ME(swfbitmap, __construct, NULL, 0)
1113 PHP_ME(swfbitmap, getWidth, NULL, 0)
1114 PHP_ME(swfbitmap, getHeight, NULL, 0)
1115 { NULL, NULL, NULL }
1116 };
1117
1118 /* }}} */
1119
1120 #ifdef HAVE_NEW_MING
1121 /* {{{ internal function */
1122 static
1123 SWFButtonRecord getButtonRecord(zval *id TSRMLS_DC)
1124 {
1125 void *record = SWFgetProperty(id, "buttonrecord", strlen("buttonrecord"), le_swfbuttonrecordp TSRMLS_CC);
1126
1127 if(!record)
1128 php_error(E_ERROR, "called object is not an SWFButtonRecord!");
1129
1130 return (SWFButtonRecord)record;
1131 }
1132 /* }}} */
1133
1134 /* {{{ proto void swfbuttoncharacter::setDepth(int depth)
1135 sets a button characters depth */
1136 PHP_METHOD(swfbuttonrecord, setDepth)
1137 {
1138 zend_long depth;
1139
1140 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &depth) == FAILURE) {
1141 return;
1142 }
1143 SWFButtonRecord_setDepth(getButtonRecord(getThis() TSRMLS_CC), depth);
1144 }
1145 /* }}} */
1146
1147 /* {{{ proto void swfbuttoncharacter::setBlendMode(int mode)
1148 assigns a blend mode to a button's character */
1149 PHP_METHOD(swfbuttonrecord, setBlendMode)
1150 {
1151 zend_long mode;
1152
1153 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) {
1154 return;
1155 }
1156 SWFButtonRecord_setBlendMode(getButtonRecord(getThis() TSRMLS_CC), mode);
1157 }
1158 /* }}} */
1159
1160 /* {{{ proto void swfbuttoncharacter::move(double x, double y)
1161 relative placement */
1162 PHP_METHOD(swfbuttonrecord, move)
1163 {
1164 double x, y;
1165
1166 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
1167 return;
1168 }
1169 SWFButtonRecord_move(getButtonRecord(getThis() TSRMLS_CC), x, y);
1170 }
1171 /* }}} */
1172
1173 /* {{{ proto void swfbuttoncharacter::moveTo(double x, double y)
1174 absolute placement */
1175 PHP_METHOD(swfbuttonrecord, moveTo)
1176 {
1177 double x, y;
1178
1179 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
1180 return;
1181 }
1182 SWFButtonRecord_moveTo(getButtonRecord(getThis() TSRMLS_CC), x, y);
1183 }
1184 /* }}} */
1185
1186 /* {{{ proto void swfbuttoncharacter::rotate(double deg)
1187 relative rotation */
1188 PHP_METHOD(swfbuttonrecord, rotate)
1189 {
1190 double deg;
1191
1192 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °) == FAILURE) {
1193 return;
1194 }
1195 SWFButtonRecord_rotate(getButtonRecord(getThis() TSRMLS_CC), deg);
1196 }
1197 /* }}} */
1198
1199 /* {{{ proto void swfbuttoncharacter::rotateTo(double deg)
1200 absolute rotation */
1201 PHP_METHOD(swfbuttonrecord, rotateTo)
1202 {
1203 double deg;
1204
1205 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °) == FAILURE) {
1206 return;
1207 }
1208 SWFButtonRecord_rotateTo(getButtonRecord(getThis() TSRMLS_CC), deg);
1209 }
1210 /* }}} */
1211
1212 /* {{{ proto void swfbuttoncharacter::scale(double x, double y)
1213 relative scaling */
1214 PHP_METHOD(swfbuttonrecord, scale)
1215 {
1216 double x, y;
1217
1218 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
1219 return;
1220 }
1221 SWFButtonRecord_scale(getButtonRecord(getThis() TSRMLS_CC), x, y);
1222 }
1223 /* }}} */
1224
1225 /* {{{ proto void swfbuttoncharacter::scaleTo(double x, double y)
1226 absolute scaling */
1227 PHP_METHOD(swfbuttonrecord, scaleTo)
1228 {
1229 double x, y;
1230
1231 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
1232 return;
1233 }
1234 SWFButtonRecord_scaleTo(getButtonRecord(getThis() TSRMLS_CC), x, y);
1235 }
1236 /* }}} */
1237
1238 /* {{{ proto void swfbuttoncharacter::skewX(double x) */
1239 PHP_METHOD(swfbuttonrecord, skewX)
1240 {
1241 double x;
1242
1243 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) {
1244 return;
1245 }
1246 SWFButtonRecord_skewX(getButtonRecord(getThis() TSRMLS_CC), x);
1247 }
1248 /* }}} */
1249
1250 /* {{{ proto void swfbuttoncharacter::skewXTo(double x) */
1251 PHP_METHOD(swfbuttonrecord, skewXTo)
1252 {
1253 double x;
1254
1255 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) {
1256 return;
1257 }
1258 SWFButtonRecord_skewXTo(getButtonRecord(getThis() TSRMLS_CC), x);
1259 }
1260 /* }}} */
1261
1262 /* {{{ proto void swfbuttoncharacter::skewY(double y) */
1263 PHP_METHOD(swfbuttonrecord, skewY)
1264 {
1265 double y;
1266
1267 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) {
1268 return;
1269 }
1270 SWFButtonRecord_skewY(getButtonRecord(getThis() TSRMLS_CC), y);
1271 }
1272 /* }}} */
1273
1274 /* {{{ proto void swfbuttoncharacter::skewYTo(double y) */
1275 PHP_METHOD(swfbuttonrecord, skewYTo)
1276 {
1277 double y;
1278
1279 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) {
1280 return;
1281 }
1282 SWFButtonRecord_skewYTo(getButtonRecord(getThis() TSRMLS_CC), y);
1283 }
1284 /* }}} */
1285
1286 /* {{{ proto void swfbuttoncharacter::addFilter(SWFFilter f) */
1287 PHP_METHOD(swfbuttonrecord, addFilter)
1288 {
1289 zval *filter;
1290
1291 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &filter) == FAILURE) {
1292 return;
1293 }
1294 SWFButtonRecord_addFilter(getButtonRecord(getThis() TSRMLS_CC), getFilter(filter TSRMLS_CC));
1295 }
1296 /* }}} */
1297
1298 static zend_function_entry swfbuttonrecord_functions[] = {
1299 PHP_ME(swfbuttonrecord, setDepth, NULL, 0)
1300 PHP_ME(swfbuttonrecord, setBlendMode, NULL, 0)
1301 PHP_ME(swfbuttonrecord, move, NULL, 0)
1302 PHP_ME(swfbuttonrecord, moveTo, NULL, 0)
1303 PHP_ME(swfbuttonrecord, rotate, NULL, 0)
1304 PHP_ME(swfbuttonrecord, rotateTo, NULL, 0)
1305 PHP_ME(swfbuttonrecord, scale, NULL, 0)
1306 PHP_ME(swfbuttonrecord, scaleTo, NULL, 0)
1307 PHP_ME(swfbuttonrecord, skewX, NULL, 0)
1308 PHP_ME(swfbuttonrecord, skewXTo, NULL, 0)
1309 PHP_ME(swfbuttonrecord, skewY, NULL, 0)
1310 PHP_ME(swfbuttonrecord, skewYTo, NULL, 0)
1311 PHP_ME(swfbuttonrecord, addFilter, NULL, 0)
1312 { NULL, NULL, NULL }
1313 };
1314 #endif
1315
1316 /* {{{ SWFButton
1317 */
1318 /* {{{ proto void swfbutton::__construct()
1319 Creates a new SWFButton object */
1320 PHP_METHOD(swfbutton, __construct)
1321 {
1322 SWFButton button = newSWFButton();
1323 #if PHP_VERSION_ID >= 70000
1324 zend_resource *ret;
1325 ret = zend_register_resource(button, le_swfbuttonp);
1326 add_property_resource(getThis(), "button", ret);
1327 #else
1328 int ret = zend_list_insert(button, le_swfbuttonp);
1329 object_init_ex(getThis(), button_class_entry_ptr);
1330 add_property_resource(getThis(), "button", ret);
1331 zend_list_addref(ret);
1332 #endif
1333 }
1334
1335 #if PHP_VERSION_ID >= 70000
1336 static void destroy_SWFButton_resource(zend_resource *resource)
1337 #else
1338 static void destroy_SWFButton_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
1339 #endif
1340 {
1341 destroySWFButton((SWFButton)resource->ptr);
1342 }
1343 /* }}} */
1344
1345 /* {{{ internal function getButton
1346 Returns the SWFButton object contained in zval *id */
1347 static SWFButton getButton(zval *id TSRMLS_DC)
1348 {
1349 void *button = SWFgetProperty(id, "button", 6, le_swfbuttonp TSRMLS_CC);
1350
1351 if (!button) {
1352 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFButton");
1353 }
1354 return (SWFButton)button;
1355 }
1356 /* }}} */
1357
1358 /* {{{ proto void swfbutton::setHit(object SWFCharacter)
1359 Sets the character for this button's hit test state */
1360 PHP_METHOD(swfbutton, setHit)
1361 {
1362 zval *zchar;
1363 SWFButton button = getButton(getThis() TSRMLS_CC);
1364 SWFCharacter character;
1365
1366 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) {
1367 return;
1368 }
1369
1370 character = getCharacter(zchar TSRMLS_CC);
1371 SWFButton_addCharacter(button, character, SWFBUTTONRECORD_HITSTATE);
1372 }
1373 /* }}} */
1374
1375 /* {{{ proto void swfbutton::setOver(object SWFCharacter)
1376 Sets the character for this button's over state */
1377 PHP_METHOD(swfbutton, setOver)
1378 {
1379 zval *zchar;
1380 SWFButton button = getButton(getThis() TSRMLS_CC);
1381 SWFCharacter character;
1382
1383 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) {
1384 return;
1385 }
1386
1387 character = getCharacter(zchar TSRMLS_CC);
1388 SWFButton_addCharacter(button, character, SWFBUTTONRECORD_OVERSTATE);
1389 }
1390 /* }}} */
1391
1392 /* {{{ proto void swfbutton::setUp(object SWFCharacter)
1393 Sets the character for this button's up state */
1394 PHP_METHOD(swfbutton, setUp)
1395 {
1396 zval *zchar;
1397 SWFButton button = getButton(getThis() TSRMLS_CC);
1398 SWFCharacter character;
1399
1400 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) {
1401 return;
1402 }
1403
1404 character = getCharacter(zchar TSRMLS_CC);
1405 SWFButton_addCharacter(button, character, SWFBUTTONRECORD_UPSTATE);
1406 }
1407 /* }}} */
1408
1409 /* {{{ proto void swfbutton::setDown(object SWFCharacter)
1410 Sets the character for this button's down state */
1411 PHP_METHOD(swfbutton, setDown)
1412 {
1413 zval *zchar;
1414 SWFButton button = getButton(getThis() TSRMLS_CC);
1415 SWFCharacter character;
1416
1417 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) {
1418 return;
1419 }
1420
1421 character = getCharacter(zchar TSRMLS_CC);
1422 SWFButton_addCharacter(button, character, SWFBUTTONRECORD_DOWNSTATE);
1423 }
1424 /* }}} */
1425
1426 /* {{{ proto void swfbutton::addShape(object SWFCharacter, int flags)
1427 Sets the character to display for the condition described in flags */
1428 PHP_METHOD(swfbutton, addShape)
1429 {
1430 zval *zchar;
1431 zend_long flags;
1432 SWFButton button = getButton(getThis() TSRMLS_CC);
1433 SWFCharacter character;
1434
1435 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zchar, &flags) == FAILURE) {
1436 return;
1437 }
1438
1439 character = getCharacter(zchar TSRMLS_CC);
1440 SWFButton_addCharacter(button, character, flags);
1441 }
1442 /* }}} */
1443
1444 #ifdef HAVE_NEW_MING
1445 /* {{{ proto swfbuttonrecord swfbutton::addCharacter(object SWFCharacter, int flags)
1446 Sets the character to display for the condition described in flags */
1447 PHP_METHOD(swfbutton, addCharacter)
1448 {
1449 zval *zchar;
1450 zend_long flags;
1451 SWFButtonRecord record;
1452 SWFButton button = getButton(getThis() TSRMLS_CC);
1453 SWFCharacter character;
1454 #if PHP_VERSION_ID >= 70000
1455 zend_resource *ret;
1456 #else
1457 int ret;
1458 #endif
1459
1460 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zchar, &flags) == FAILURE) {
1461 return;
1462 }
1463
1464 character = getCharacter(zchar TSRMLS_CC);
1465 record = SWFButton_addCharacter(button, character, flags);
1466
1467 if(record != NULL)
1468 {
1469 object_init_ex(return_value, buttonrecord_class_entry_ptr);
1470 #if PHP_VERSION_ID >= 70000
1471 ret = zend_register_resource(record, le_swfbuttonrecordp);
1472 add_property_resource(return_value, "buttonrecord", ret);
1473 ret->gc.refcount++;
1474 #else
1475 ret = zend_list_insert(record, le_swfbuttonrecordp);
1476 add_property_resource(return_value, "buttonrecord", ret);
1477 zend_list_addref(ret);
1478 #endif
1479 }
1480 }
1481 /* }}} */
1482
1483 /* {{{ proto void swfbutton::setMenu(int flag)
1484 enable track as menu button behaviour */
1485 PHP_METHOD(swfbutton, setMenu)
1486 {
1487 zend_long flag;
1488 SWFButton button = getButton(getThis() TSRMLS_CC);
1489
1490 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) {
1491 return;
1492 }
1493 SWFButton_setMenu(button, flag);
1494 }
1495 /* }}} */
1496
1497 /* {{{ proto void swfbutton::setScalingGrid(int x, int y, int w, int h) */
1498 PHP_METHOD(swfbutton, setScalingGrid)
1499 {
1500 zend_long x, y, w, h;
1501 SWFButton button = getButton(getThis() TSRMLS_CC);
1502
1503 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &x, &y, &w, &h) == FAILURE) {
1504 return;
1505 }
1506 SWFButton_setScalingGrid(button, x, y, w, h);
1507 }
1508 /* }}} */
1509
1510 /* {{{ proto void swfbutton::removeScalingGrid() */
1511 PHP_METHOD(swfbutton, removeScalingGrid)
1512 {
1513 SWFButton button = getButton(getThis() TSRMLS_CC);
1514 if (ZEND_NUM_ARGS() != 0) {
1515 WRONG_PARAM_COUNT;
1516 }
1517 SWFButton_removeScalingGrid(button);
1518 }
1519 /* }}} */
1520 #endif
1521
1522 /* {{{ proto void swfbutton::setAction(object SWFAction)
1523 Sets the action to perform when button is pressed */
1524 PHP_METHOD(swfbutton, setAction)
1525 {
1526 zval *zaction;
1527 SWFButton button = getButton(getThis() TSRMLS_CC);
1528 SWFAction action;
1529
1530 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zaction) == FAILURE) {
1531 return;
1532 }
1533
1534 action = getAction(zaction TSRMLS_CC);
1535 SWFButton_addAction(button, action, SWFBUTTON_OVERDOWNTOOVERUP);
1536 }
1537 /* }}} */
1538
1539 #ifdef HAVE_NEW_MING
1540 /* {{{ proto SWFSoundInstance swfbutton::addASound(SWFSound sound, int flags)
1541 associates a sound with a button transition
1542 NOTE: the transitions are all wrong _UP, _OVER, _DOWN _HIT */
1543
1544 PHP_METHOD(swfbutton, addSound)
1545 {
1546 zval *zsound;
1547 zend_long flags;
1548 SWFButton button = getButton(getThis() TSRMLS_CC);
1549 SWFSound sound;
1550 SWFSoundInstance item;
1551 #if PHP_VERSION_ID >= 70000
1552 zend_resource *ret;
1553 #else
1554 int ret;
1555 #endif
1556
1557 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zsound, &flags) == FAILURE) {
1558 return;
1559 }
1560
1561 sound = getSound(zsound TSRMLS_CC);
1562 item = SWFButton_addSound(button, sound, flags);
1563
1564 if(item != NULL) {
1565 /* try and create a soundinstance object */
1566 object_init_ex(return_value, soundinstance_class_entry_ptr);
1567 #if PHP_VERSION_ID >= 70000
1568 ret = zend_register_resource(item, le_swfsoundinstancep);
1569 add_property_resource(return_value, "soundinstance", ret);
1570 ret->gc.refcount++;
1571 #else
1572 ret = zend_list_insert(item, le_swfsoundinstancep);
1573 add_property_resource(return_value, "soundinstance", ret);
1574 zend_list_addref(ret);
1575 #endif
1576 }
1577 }
1578 /* }}} */
1579 #endif
1580
1581 /* {{{ proto void swfbutton::addAction(object SWFAction, int flags)
1582 Sets the action to perform when conditions described in flags is met */
1583 PHP_METHOD(swfbutton, addAction)
1584 {
1585 zval *zaction;
1586 zend_long flags;
1587 SWFButton button = getButton(getThis() TSRMLS_CC);
1588 SWFAction action;
1589
1590 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zaction, &flags) == FAILURE) {
1591 return;
1592 }
1593
1594 action = getAction(zaction TSRMLS_CC);
1595 SWFButton_addAction(button, action, flags);
1596 }
1597 /* }}} */
1598
1599 /* {{{ proto int ming_keypress(string str)
1600 Returns the action flag for keyPress(char) */
1601 PHP_FUNCTION(ming_keypress)
1602 {
1603 char *key;
1604 zend_strlen key_len;
1605 char c;
1606
1607 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) {
1608 return;
1609 }
1610
1611 if (key_len > 1) {
1612 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Only one character expected");
1613 }
1614
1615 c = key[0];
1616 RETURN_LONG((c&0x7f)<<9);
1617 }
1618 /* }}} */
1619
1620 static zend_function_entry swfbutton_functions[] = {
1621 PHP_ME(swfbutton, __construct, NULL, 0)
1622 PHP_ME(swfbutton, setHit, NULL, 0)
1623 PHP_ME(swfbutton, setOver, NULL, 0)
1624 PHP_ME(swfbutton, setUp, NULL, 0)
1625 PHP_ME(swfbutton, setDown, NULL, 0)
1626 PHP_ME(swfbutton, setAction, NULL, 0)
1627 PHP_ME(swfbutton, addShape, NULL, 0)
1628 #ifdef HAVE_NEW_MING
1629 PHP_ME(swfbutton, setMenu, NULL, 0)
1630 PHP_ME(swfbutton, setScalingGrid, NULL, 0)
1631 PHP_ME(swfbutton, removeScalingGrid, NULL, 0)
1632 #endif
1633 PHP_ME(swfbutton, addAction, NULL, 0)
1634 #ifdef HAVE_NEW_MING
1635 PHP_ME(swfbutton, addSound, NULL, 0)
1636 PHP_ME(swfbutton, addCharacter, NULL, 0)
1637 #endif
1638 { NULL, NULL, NULL }
1639 };
1640
1641 /* }}} */
1642
1643 /* {{{ SWFDisplayItem
1644 */
1645 /* {{{ internal function getDisplayItem
1646 Returns the SWFDisplayItem contained in zval *id */
1647 static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC)
1648 {
1649 void *item = SWFgetProperty(id, "displayitem", 11, le_swfdisplayitemp TSRMLS_CC);
1650
1651 if (!item) {
1652 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFDisplayItem");
1653 }
1654
1655 return (SWFDisplayItem)item;
1656 }
1657 /* }}} */
1658
1659 /* {{{ proto void swfdisplayitem::moveTo(double x, double y)
1660 Moves this SWFDisplayItem to movie coordinates (x, y) */
1661 PHP_METHOD(swfdisplayitem, moveTo)
1662 {
1663 double x, y;
1664
1665 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
1666 return;
1667 }
1668
1669 SWFDisplayItem_moveTo(getDisplayItem(getThis() TSRMLS_CC), x, y);
1670 }
1671 /* }}} */
1672
1673 /* {{{ proto void swfdisplayitem::move(double dx, double dy)
1674 Displaces this SWFDisplayItem by (dx, dy) in movie coordinates */
1675 PHP_METHOD(swfdisplayitem, move)
1676 {
1677 double x, y;
1678
1679 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
1680 return;
1681 }
1682
1683 SWFDisplayItem_move(getDisplayItem(getThis() TSRMLS_CC), x, y);
1684 }
1685 /* }}} */
1686
1687 /* {{{ proto void swfdisplayitem::scaleTo(double xScale [, double yScale])
1688 Scales this SWFDisplayItem by xScale in the x direction, yScale in the y, or both to xScale if only one arg */
1689 PHP_METHOD(swfdisplayitem, scaleTo)
1690 {
1691 double x, y;
1692
1693 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &x, &y) == FAILURE) {
1694 return;
1695 }
1696
1697 if (ZEND_NUM_ARGS() == 1) {
1698 y = x;
1699 }
1700 SWFDisplayItem_scaleTo(getDisplayItem(getThis() TSRMLS_CC), x, y);
1701 }
1702 /* }}} */
1703
1704 /* {{{ proto void swfdisplayitem::scale(double xScale, double yScale)
1705 Multiplies this SWFDisplayItem's current x scale by xScale, its y scale by yScale */
1706 PHP_METHOD(swfdisplayitem, scale)
1707 {
1708 double x, y;
1709
1710 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
1711 return;
1712 }
1713
1714 SWFDisplayItem_scale(getDisplayItem(getThis() TSRMLS_CC), x, y);
1715 }
1716 /* }}} */
1717
1718 /* {{{ proto void swfdisplayitem::rotateTo(double degrees)
1719 Rotates this SWFDisplayItem the given (clockwise) degrees from its original orientation */
1720 PHP_METHOD(swfdisplayitem, rotateTo)
1721 {
1722 double degrees;
1723
1724 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) {
1725 return;
1726 }
1727
1728 SWFDisplayItem_rotateTo(getDisplayItem(getThis() TSRMLS_CC), degrees);
1729 }
1730 /* }}} */
1731
1732 /* {{{ proto void swfdisplayitem::rotate(double degrees)
1733 Rotates this SWFDisplayItem the given (clockwise) degrees from its current orientation */
1734 PHP_METHOD(swfdisplayitem, rotate)
1735 {
1736 double degrees;
1737
1738 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) {
1739 return;
1740 }
1741
1742 SWFDisplayItem_rotate(getDisplayItem(getThis() TSRMLS_CC), degrees);
1743 }
1744 /* }}} */
1745
1746 /* {{{ proto void swfdisplayitem::skewXTo(double xSkew)
1747 Sets this SWFDisplayItem's x skew value to xSkew */
1748 PHP_METHOD(swfdisplayitem, skewXTo)
1749 {
1750 double x;
1751
1752 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) {
1753 return;
1754 }
1755
1756 SWFDisplayItem_skewXTo(getDisplayItem(getThis() TSRMLS_CC), x);
1757 }
1758 /* }}} */
1759
1760 /* {{{ proto void swfdisplayitem::skewX(double xSkew)
1761 Adds xSkew to this SWFDisplayItem's x skew value */
1762 PHP_METHOD(swfdisplayitem, skewX)
1763 {
1764 double x;
1765
1766 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) {
1767 return;
1768 }
1769
1770 SWFDisplayItem_skewX(getDisplayItem(getThis() TSRMLS_CC), x);
1771 }
1772 /* }}} */
1773
1774 /* {{{ proto void swfdisplayitem::skewYTo(double ySkew)
1775 Sets this SWFDisplayItem's y skew value to ySkew */
1776 PHP_METHOD(swfdisplayitem, skewYTo)
1777 {
1778 double y;
1779
1780 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) {
1781 return;
1782 }
1783
1784 SWFDisplayItem_skewYTo(getDisplayItem(getThis() TSRMLS_CC), y);
1785 }
1786 /* }}} */
1787
1788 /* {{{ proto void swfdisplayitem::skewY(double ySkew)
1789 Adds ySkew to this SWFDisplayItem's y skew value */
1790 PHP_METHOD(swfdisplayitem, skewY)
1791 {
1792 double y;
1793
1794 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) {
1795 return;
1796 }
1797
1798 SWFDisplayItem_skewY(getDisplayItem(getThis() TSRMLS_CC), y);
1799 }
1800 /* }}} */
1801
1802 /* {{{ proto void swfdisplayitem::setMatrix(double a, double b, double c, double d, double x, double y)
1803 Sets the item's transform matrix */
1804 PHP_METHOD(swfdisplayitem, setMatrix)
1805 {
1806 double a, b, c, d, x, y;
1807
1808 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &a, &b, &c, &d, &x, &y) == FAILURE) {
1809 return;
1810 }
1811
1812 SWFDisplayItem_setMatrix( getDisplayItem(getThis() TSRMLS_CC), a, b, c, d, x, y);
1813 }
1814 /* }}} */
1815
1816 /* {{{ proto void swfdisplayitem::setDepth(int depth)
1817 Sets this SWFDisplayItem's z-depth to depth. Items with higher depth values are drawn on top of those with lower values */
1818 PHP_METHOD(swfdisplayitem, setDepth)
1819 {
1820 zend_long depth;
1821
1822 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &depth) == FAILURE) {
1823 return;
1824 }
1825
1826 SWFDisplayItem_setDepth(getDisplayItem(getThis() TSRMLS_CC), depth);
1827 }
1828 /* }}} */
1829
1830 /* {{{ proto void swfdisplayitem::setRatio(float ratio)
1831 Sets this SWFDisplayItem's ratio to ratio. Obviously only does anything if displayitem was created from an SWFMorph */
1832 PHP_METHOD(swfdisplayitem, setRatio)
1833 {
1834 double ratio;
1835
1836 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &ratio) == FAILURE) {
1837 return;
1838 }
1839
1840 SWFDisplayItem_setRatio(getDisplayItem(getThis() TSRMLS_CC), ratio);
1841 }
1842 /* }}} */
1843
1844 /* {{{ proto void swfdisplayitem::addColor(int r, int g, int b [, int a])
1845 Sets the add color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 0 */
1846 PHP_METHOD(swfdisplayitem, addColor)
1847 {
1848 zend_long r, g, b, a = 0;
1849
1850 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) {
1851 return;
1852 }
1853
1854 SWFDisplayItem_setColorAdd(getDisplayItem(getThis() TSRMLS_CC), r, g, b, (int)a);
1855 }
1856 /* }}} */
1857
1858 /* {{{ proto void swfdisplayitem::multColor(float r, float g, float b [, float a])
1859 Sets the multiply color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 1.0 */
1860 PHP_METHOD(swfdisplayitem, multColor)
1861 {
1862 double r, g, b, a = 1.0;
1863
1864 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd|d", &r, &g, &b, &a) == FAILURE) {
1865 return;
1866 }
1867
1868 SWFDisplayItem_setColorMult(getDisplayItem(getThis() TSRMLS_CC), r, g, b, a);
1869 }
1870 /* }}} */
1871
1872 /* {{{ proto void swfdisplayitem::setName(string name)
1873 Sets this SWFDisplayItem's name to name */
1874 PHP_METHOD(swfdisplayitem, setName)
1875 {
1876 char *name;
1877 zend_strlen name_len;
1878
1879 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
1880
1881 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
1882 return;
1883 }
1884
1885 SWFDisplayItem_setName(item, name);
1886 }
1887 /* }}} */
1888
1889 /* {{{ proto void swfdisplayitem::addAction(object SWFAction, int flags)
1890 Adds this SWFAction to the given SWFSprite instance */
1891 PHP_METHOD(swfdisplayitem, addAction)
1892 {
1893 zval *zaction;
1894 zend_long flags;
1895 SWFAction action;
1896 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
1897
1898 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zaction, &flags) == FAILURE) {
1899 return;
1900 }
1901
1902 action = getAction(zaction TSRMLS_CC);
1903 SWFDisplayItem_addAction(item, action, flags);
1904 }
1905 /* }}} */
1906
1907 #ifdef HAVE_NEW_MING
1908 /* {{{ swfdisplayitem_remove */
1909
1910 PHP_METHOD(swfdisplayitem, remove)
1911 {
1912 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
1913
1914 if (ZEND_NUM_ARGS() != 0) {
1915 WRONG_PARAM_COUNT;
1916 }
1917
1918 SWFDisplayItem_remove(item);
1919 }
1920 /* }}} */
1921
1922 /* {{{ proto void swfdisplayitem::setMaskLevel(int level)
1923 defines a MASK layer at level */
1924
1925 PHP_METHOD(swfdisplayitem, setMaskLevel)
1926 {
1927 zend_long level;
1928
1929 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level) == FAILURE) {
1930 return;
1931 }
1932
1933 SWFDisplayItem_setMaskLevel(getDisplayItem(getThis() TSRMLS_CC), level);
1934 }
1935 /* }}} */
1936
1937 /* {{{ proto void swfdisplayitem::endMask()
1938 another way of defining a MASK layer */
1939
1940 PHP_METHOD(swfdisplayitem, endMask)
1941 {
1942 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
1943
1944 if (ZEND_NUM_ARGS() != 0) {
1945 WRONG_PARAM_COUNT;
1946 }
1947
1948 SWFDisplayItem_endMask(item);
1949 }
1950 /* }}} */
1951
1952 /* {{{ swfdisplayitem_getX */
1953
1954 PHP_METHOD(swfdisplayitem, getX)
1955 {
1956 double x, y;
1957 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
1958
1959 if (ZEND_NUM_ARGS() != 0) {
1960 WRONG_PARAM_COUNT;
1961 }
1962
1963 SWFDisplayItem_getPosition(item, &x, &y);
1964 RETURN_DOUBLE(x);
1965 }
1966 /* }}} */
1967
1968 /* {{{ swfdisplayitem_getY */
1969
1970 PHP_METHOD(swfdisplayitem, getY)
1971 {
1972 double x, y;
1973 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
1974
1975 if (ZEND_NUM_ARGS() != 0) {
1976 WRONG_PARAM_COUNT;
1977 }
1978
1979 SWFDisplayItem_getPosition(item, &x, &y);
1980 RETURN_DOUBLE(y);
1981 }
1982 /* }}} */
1983
1984 /* {{{ swfdisplayitem_getXScale */
1985
1986 PHP_METHOD(swfdisplayitem, getXScale)
1987 {
1988 double sx, sy;
1989 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
1990
1991 if (ZEND_NUM_ARGS() != 0) {
1992 WRONG_PARAM_COUNT;
1993 }
1994
1995 SWFDisplayItem_getScale(item, &sx, &sy);
1996 RETURN_DOUBLE(sx);
1997 }
1998 /* }}} */
1999
2000 /* {{{ swfdisplayitem_getYScale */
2001
2002 PHP_METHOD(swfdisplayitem, getYScale)
2003 {
2004 double sx, sy;
2005 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
2006
2007 if (ZEND_NUM_ARGS() != 0) {
2008 WRONG_PARAM_COUNT;
2009 }
2010
2011 SWFDisplayItem_getScale(item, &sx, &sy);
2012 RETURN_DOUBLE(sy);
2013 }
2014 /* }}} */
2015
2016 /* {{{ swfdisplayitem_getXSkew */
2017
2018 PHP_METHOD(swfdisplayitem, getXSkew)
2019 {
2020 double sx, sy;
2021 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
2022
2023 if (ZEND_NUM_ARGS() != 0) {
2024 WRONG_PARAM_COUNT;
2025 }
2026
2027 SWFDisplayItem_getSkew(item, &sx, &sy);
2028 RETURN_DOUBLE(sx);
2029 }
2030 /* }}} */
2031
2032 /* {{{ swfdisplayitem_getYSkew */
2033
2034 PHP_METHOD(swfdisplayitem, getYSkew)
2035 {
2036 double sx, sy;
2037 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
2038
2039 if (ZEND_NUM_ARGS() != 0) {
2040 WRONG_PARAM_COUNT;
2041 }
2042
2043 SWFDisplayItem_getSkew(item, &sx, &sy);
2044 RETURN_DOUBLE(sy);
2045 }
2046 /* }}} */
2047
2048 /* {{{ swfdisplayitem_getRot */
2049
2050 PHP_METHOD(swfdisplayitem, getRot)
2051 {
2052 double ret;
2053 SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
2054
2055 if (ZEND_NUM_ARGS() != 0) {
2056 WRONG_PARAM_COUNT;
2057 }
2058
2059 SWFDisplayItem_getRotation(item, &ret);
2060 RETURN_DOUBLE(ret);
2061 }
2062 /* }}} */
2063
2064 /* {{{ proto void swfdisplayitem::cacheAsBitmap(int flag)
2065 caches item as bitmap. can improve rendering speed */
2066
2067 PHP_METHOD(swfdisplayitem, cacheAsBitmap)
2068 {
2069 zend_long flag;
2070
2071 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) {
2072 return;
2073 }
2074
2075 SWFDisplayItem_cacheAsBitmap(getDisplayItem(getThis() TSRMLS_CC), flag);
2076 }
2077 /* }}} */
2078
2079
2080 /* {{{ proto void swfdisplayitem::setBlendMode(int mode)
2081 adds blending to item */
2082 PHP_METHOD(swfdisplayitem, setBlendMode)
2083 {
2084 zend_long mode;
2085
2086 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) {
2087 return;
2088 }
2089
2090 SWFDisplayItem_cacheAsBitmap(getDisplayItem(getThis() TSRMLS_CC), mode);
2091 }
2092 /* }}} */
2093
2094 /* {{{ proto int swfdisplayitem::setDepth()
2095 gets the items depth */
2096 PHP_METHOD(swfdisplayitem, getDepth)
2097 {
2098 int ret;
2099
2100 if (ZEND_NUM_ARGS() != 0) {
2101 WRONG_PARAM_COUNT;
2102 }
2103
2104 ret = SWFDisplayItem_getDepth(getDisplayItem(getThis() TSRMLS_CC));
2105 RETURN_LONG(ret);
2106 }
2107 /* }}} */
2108
2109 /* {{{ proto int swfdisplayitem::flush() */
2110 PHP_METHOD(swfdisplayitem, flush)
2111 {
2112 if (ZEND_NUM_ARGS() != 0) {
2113 WRONG_PARAM_COUNT;
2114 }
2115
2116 SWFDisplayItem_flush(getDisplayItem(getThis() TSRMLS_CC));
2117 }
2118 /* }}} */
2119
2120 /* {{{ proto void swfdisplayitem::addFilter(SWFFilter filter) */
2121 PHP_METHOD(swfdisplayitem, addFilter)
2122 {
2123 zval *filter;
2124
2125 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &filter) == FAILURE) {
2126 return;
2127 }
2128
2129 SWFDisplayItem_addFilter(getDisplayItem(getThis() TSRMLS_CC), getFilter(filter TSRMLS_CC));
2130
2131 }
2132 /* }}} */
2133
2134 /* {{{ proto void swfdisplayitem::setCXform(cx) */
2135 PHP_METHOD(swfdisplayitem, setCXform)
2136 {
2137 zval *cx;
2138
2139 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &cx) == FAILURE) {
2140 return;
2141 }
2142
2143 SWFDisplayItem_setCXform(getDisplayItem(getThis() TSRMLS_CC), getCXform(cx TSRMLS_CC));
2144 }
2145 /* }}} */
2146
2147 /** {{{ proto void swfdisplayitem::getMatrix() */
2148 PHP_METHOD(swfdisplayitem, getMatrix)
2149 {
2150 SWFMatrix m;
2151 #if PHP_VERSION_ID >= 70000
2152 zend_resource *ret;
2153 #else
2154 int ret;
2155 #endif
2156
2157 if (ZEND_NUM_ARGS() != 0) {
2158 WRONG_PARAM_COUNT;
2159 }
2160
2161 m = SWFDisplayItem_getMatrix(getDisplayItem(getThis() TSRMLS_CC));
2162 if(m != NULL)
2163 {
2164 object_init_ex(return_value, matrix_class_entry_ptr);
2165 #if PHP_VERSION_ID >= 70000
2166 ret = zend_register_resource(m, le_swfmatrixp);
2167 add_property_resource(return_value, "matrix", ret);
2168 ret->gc.refcount++;
2169 #else
2170 ret = zend_list_insert(m, le_swfmatrixp);
2171 add_property_resource(return_value, "matrix", ret);
2172 zend_list_addref(ret);
2173 #endif
2174 }
2175 }
2176 /* }}} */
2177
2178 /** {{{ proto void swfdisplayitem::getCharacter() */
2179 PHP_METHOD(swfdisplayitem, getCharacter)
2180 {
2181 SWFCharacter c;
2182 #if PHP_VERSION_ID >= 70000
2183 zend_resource *ret;
2184 #else
2185 int ret;
2186 #endif
2187
2188 if (ZEND_NUM_ARGS() != 0) {
2189 WRONG_PARAM_COUNT;
2190 }
2191
2192 c = SWFDisplayItem_getCharacter(getDisplayItem(getThis() TSRMLS_CC));
2193 if(c != NULL)
2194 {
2195 object_init_ex(return_value, character_class_entry_ptr);
2196 #if PHP_VERSION_ID >= 70000
2197 ret = zend_register_resource(c, le_swfcharacterp);
2198 add_property_resource(return_value, "character", ret);
2199 ret->gc.refcount++;
2200 #else
2201 ret = zend_list_insert(c, le_swfcharacterp);
2202 add_property_resource(return_value, "character", ret);
2203 zend_list_addref(ret);
2204 #endif
2205 }
2206 }
2207 /* }}} */
2208
2209 #endif
2210
2211 static zend_function_entry swfdisplayitem_functions[] = {
2212 PHP_ME(swfdisplayitem, moveTo, NULL, 0)
2213 PHP_ME(swfdisplayitem, move, NULL, 0)
2214 PHP_ME(swfdisplayitem, scaleTo, NULL, 0)
2215 PHP_ME(swfdisplayitem, scale, NULL, 0)
2216 PHP_ME(swfdisplayitem, rotateTo, NULL, 0)
2217 PHP_ME(swfdisplayitem, rotate, NULL, 0)
2218 PHP_ME(swfdisplayitem, skewXTo, NULL, 0)
2219 PHP_ME(swfdisplayitem, skewX, NULL, 0)
2220 PHP_ME(swfdisplayitem, skewYTo, NULL, 0)
2221 PHP_ME(swfdisplayitem, skewY, NULL, 0)
2222 PHP_ME(swfdisplayitem, setMatrix, NULL, 0)
2223 PHP_ME(swfdisplayitem, setDepth, NULL, 0)
2224 PHP_ME(swfdisplayitem, setRatio, NULL, 0)
2225 PHP_ME(swfdisplayitem, addColor, NULL, 0)
2226 PHP_ME(swfdisplayitem, multColor, NULL, 0)
2227 PHP_ME(swfdisplayitem, setName, NULL, 0)
2228 PHP_ME(swfdisplayitem, addAction, NULL, 0)
2229 #ifdef HAVE_NEW_MING
2230 PHP_ME(swfdisplayitem, remove, NULL, 0)
2231 PHP_ME(swfdisplayitem, setMaskLevel,NULL, 0)
2232 PHP_ME(swfdisplayitem, endMask, NULL, 0)
2233 PHP_ME(swfdisplayitem, getX, NULL, 0)
2234 PHP_ME(swfdisplayitem, getY, NULL, 0)
2235 PHP_ME(swfdisplayitem, getXScale, NULL, 0)
2236 PHP_ME(swfdisplayitem, getYScale, NULL, 0)
2237 PHP_ME(swfdisplayitem, getXSkew, NULL, 0)
2238 PHP_ME(swfdisplayitem, getYSkew, NULL, 0)
2239 PHP_ME(swfdisplayitem, getRot, NULL, 0)
2240 PHP_ME(swfdisplayitem, cacheAsBitmap, NULL, 0)
2241 PHP_ME(swfdisplayitem, setBlendMode, NULL, 0)
2242 PHP_ME(swfdisplayitem, getDepth, NULL, 0)
2243 PHP_ME(swfdisplayitem, flush, NULL, 0)
2244 PHP_ME(swfdisplayitem, addFilter, NULL, 0)
2245 PHP_ME(swfdisplayitem, setCXform, NULL, 0)
2246 PHP_ME(swfdisplayitem, getCharacter, NULL, 0)
2247 #endif
2248 { NULL, NULL, NULL }
2249 };
2250
2251 /* }}} */
2252
2253 /* {{{ SWFFill
2254 */
2255 /* {{{ proto void swffill::__construct()
2256 Creates a new SWFFill object */
2257 PHP_METHOD(swffill, __construct)
2258 {
2259 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Instantiating SWFFill won't do any good- use SWFShape::addFill() instead");
2260 }
2261
2262 #if PHP_VERSION_ID >= 70000
2263 static void destroy_SWFFill_resource(zend_resource *resource)
2264 #else
2265 static void destroy_SWFFill_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
2266 #endif
2267 {
2268 /* this only destroys the shallow wrapper for SWFFillStyle,
2269 which SWFShape destroys. So everything's okay. I hope. */
2270
2271 destroySWFFill((SWFFill)resource->ptr);
2272 }
2273 /* }}} */
2274
2275 /* {{{ internal function getFill
2276 Returns the SWFFill object contained in zval *id */
2277 static SWFFill getFill(zval *id TSRMLS_DC)
2278 {
2279 void *fill = SWFgetProperty(id, "fill", 4, le_swffillp TSRMLS_CC);
2280
2281 if (!fill) {
2282 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFill");
2283 }
2284 return (SWFFill)fill;
2285 }
2286 /* }}} */
2287
2288 /* {{{ proto void swffill::moveTo(float x, float y)
2289 Moves this SWFFill to shape coordinates (x,y) */
2290 PHP_METHOD(swffill, moveTo)
2291 {
2292 double x, y;
2293
2294 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
2295 return;
2296 }
2297
2298 SWFFill_moveTo(getFill(getThis() TSRMLS_CC), x, y);
2299 }
2300 /* }}} */
2301
2302 /* {{{ proto void swffill::move(float dx, float dy)
2303 Moves this SWFFill by (dx,dy) */
2304 PHP_METHOD(swffill, move)
2305 {
2306 double x, y;
2307
2308 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
2309 return;
2310 }
2311
2312 SWFFill_move(getFill(getThis() TSRMLS_CC), x, y);
2313 }
2314 /* }}} */
2315
2316
2317 /* {{{ proto void swffill::scaleTo(float xScale [, float yScale])
2318 Scales this SWFFill by xScale in the x direction, yScale in the y, or both to xScale if only one arg */
2319 PHP_METHOD(swffill, scaleTo)
2320 {
2321 double x, y;
2322
2323 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &x, &y) == FAILURE) {
2324 return;
2325 }
2326
2327 if (ZEND_NUM_ARGS() == 1) {
2328 y = x;
2329 }
2330 SWFFill_scaleXYTo(getFill(getThis() TSRMLS_CC), x, y);
2331 }
2332 /* }}} */
2333
2334 /* {{{ proto void swffill::scale(float xScale [, float yScale])
2335 Scales this SWFFill by xScale in the x direction, yScale in the y, or both to xScale if only one arg */
2336 PHP_METHOD(swffill, scale)
2337 {
2338 double x, y;
2339
2340 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &x, &y) == FAILURE) {
2341 return;
2342 }
2343
2344 if (ZEND_NUM_ARGS() == 1) {
2345 y = x;
2346 }
2347 SWFFill_scaleXY(getFill(getThis() TSRMLS_CC), x, y);
2348 }
2349 /* }}} */
2350
2351
2352 /* {{{ proto void swffill::rotateTo(float degrees)
2353 Rotates this SWFFill the given (clockwise) degrees from its original orientation */
2354 PHP_METHOD(swffill, rotateTo)
2355 {
2356 double degrees;
2357
2358 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) {
2359 return;
2360 }
2361
2362 SWFFill_rotateTo(getFill(getThis() TSRMLS_CC), degrees);
2363 }
2364 /* }}} */
2365
2366 /* {{{ proto void swffill::rotate(float degrees)
2367 Rotates this SWFFill the given (clockwise) degrees from its current orientation */
2368 PHP_METHOD(swffill, rotate)
2369 {
2370 double degrees;
2371
2372 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) {
2373 return;
2374 }
2375
2376 SWFFill_rotate(getFill(getThis() TSRMLS_CC), degrees);
2377 }
2378 /* }}} */
2379
2380
2381 /* {{{ proto void swffill::skewXTo(float xSkew)
2382 Sets this SWFFill's x skew value to xSkew */
2383 PHP_METHOD(swffill, skewXTo)
2384 {
2385 double x;
2386
2387 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) {
2388 return;
2389 }
2390
2391 SWFFill_skewXTo(getFill(getThis() TSRMLS_CC), x);
2392 }
2393 /* }}} */
2394
2395 /* {{{ proto void swffill::skewX(float xSkew)
2396 Sets this SWFFill's x skew value to xSkew */
2397 PHP_METHOD(swffill, skewX)
2398 {
2399 double x;
2400
2401 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) {
2402 return;
2403 }
2404
2405 SWFFill_skewX(getFill(getThis() TSRMLS_CC), x);
2406 }
2407 /* }}} */
2408
2409 /* {{{ proto void swffill::skewYTo(float ySkew)
2410 Sets this SWFFill's y skew value to ySkew */
2411 PHP_METHOD(swffill, skewYTo)
2412 {
2413 double y;
2414
2415 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) {
2416 return;
2417 }
2418
2419 SWFFill_skewYTo(getFill(getThis() TSRMLS_CC), y);
2420 }
2421 /* }}} */
2422
2423 /* {{{ proto void swffill::skewY(float ySkew)
2424 Sets this SWFFill's y skew value to ySkew */
2425 PHP_METHOD(swffill, skewY)
2426 {
2427 double y;
2428
2429 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) {
2430 return;
2431 }
2432
2433 SWFFill_skewY(getFill(getThis() TSRMLS_CC), y);
2434 }
2435 /* }}} */
2436
2437 /* {{{ proto void swffill::setMatrix(float a, float b, float c, float d, float x, float y)
2438 Sets this SWFFill's y matrix values */
2439 PHP_METHOD(swffill, setMatrix)
2440 {
2441 double a, b, c, d, x, y;
2442
2443 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &a, &b, &c, &d, &x, &y) == FAILURE) {
2444 return;
2445 }
2446
2447 SWFFill_setMatrix(getFill(getThis() TSRMLS_CC), a, b, c, d, x, y);
2448 }
2449 /* }}} */
2450
2451 static zend_function_entry swffill_functions[] = {
2452 PHP_ME(swffill, __construct, NULL, 0)
2453 PHP_ME(swffill, moveTo, NULL, 0)
2454 PHP_ME(swffill, move, NULL, 0)
2455 PHP_ME(swffill, scaleTo, NULL, 0)
2456 PHP_ME(swffill, scale, NULL, 0)
2457 PHP_ME(swffill, rotateTo, NULL, 0)
2458 PHP_ME(swffill, rotate, NULL, 0)
2459 PHP_ME(swffill, skewXTo, NULL, 0)
2460 PHP_ME(swffill, skewX, NULL, 0)
2461 PHP_ME(swffill, skewYTo, NULL, 0)
2462 PHP_ME(swffill, skewY, NULL, 0)
2463 PHP_ME(swffill, setMatrix, NULL, 0)
2464 { NULL, NULL, NULL }
2465 };
2466
2467 /* }}} */
2468
2469 /* {{{ SWFFontCharacter */
2470 #ifdef HAVE_NEW_MING
2471
2472 /* {{{ internal function SWFText getFont(zval *id)
2473 Returns the Font object in zval *id */
2474 static
2475 SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC)
2476 {
2477 void *font = SWFgetProperty(id, "fontcharacter", 13, le_swffontcharp TSRMLS_CC);
2478
2479 if(!font)
2480 php_error(E_ERROR, "called object is not an SWFFontCharacter!");
2481
2482 return (SWFFontCharacter)font;
2483 }
2484 /* }}} */
2485
2486 /* {{{ proto void swffontcha::raddChars(string)
2487 adds characters to a font for exporting font */
2488 PHP_METHOD(swffontchar, addChars)
2489 {
2490 char *string;
2491 zend_strlen string_len;
2492
2493 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
2494 return;
2495 }
2496
2497 SWFFontCharacter_addChars(getFontCharacter(getThis() TSRMLS_CC), string);
2498 }
2499 /* }}} */
2500
2501 /* {{{ proto void swffontchar::addChars(string)
2502 adds characters to a font for exporting font */
2503
2504 PHP_METHOD(swffontchar, addUTF8Chars)
2505 {
2506 char *string;
2507 zend_strlen string_len;
2508
2509 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
2510 return;
2511 }
2512
2513 SWFFontCharacter_addUTF8Chars(getFontCharacter(getThis() TSRMLS_CC), string);
2514 }
2515 /* }}} */
2516
2517 /* {{{ proto void swffontchar::addAllChars()
2518 * adds all characters to a font for exporting font */
2519
2520 PHP_METHOD(swffontchar, addAllChars)
2521 {
2522 if (ZEND_NUM_ARGS() != 0 ) {
2523 WRONG_PARAM_COUNT;
2524 }
2525
2526 SWFFontCharacter_addAllChars(getFontCharacter(getThis() TSRMLS_CC));
2527 }
2528 /* }}} */
2529
2530 static zend_function_entry swffontchar_functions[] = {
2531 PHP_ME(swffontchar, addChars, NULL, 0)
2532 PHP_ME(swffontchar, addUTF8Chars, NULL, 0)
2533 PHP_ME(swffontchar, addAllChars, NULL, 0)
2534 { NULL, NULL, NULL }
2535 };
2536
2537 #endif
2538 /* }}} */
2539
2540 /* {{{ internal function SWFText getFont(zval *id)
2541 Returns the Font object in zval *id */
2542 static SWFFont getFont(zval *id TSRMLS_DC)
2543 {
2544 void *font = SWFgetProperty(id, "font", 4, le_swffontp TSRMLS_CC);
2545
2546 if (!font) {
2547 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFont");
2548 }
2549 return (SWFFont)font;
2550 }
2551 /* }}} */
2552
2553 /* {{{ proto void swffont::__construct(string filename)
2554 Creates a new SWFFont object from given file */
2555 PHP_METHOD(swffont, __construct)
2556 {
2557 char *file;
2558 zend_strlen file_len;
2559 SWFFont font;
2560 #if PHP_VERSION_ID >= 70000
2561 zend_resource *ret;
2562 #else
2563 int ret;
2564 #endif
2565
2566 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
2567 return;
2568 }
2569
2570 PHP_MING_FILE_CHK(file);
2571 font = newSWFFont_fromFile(file);
2572
2573 if(font == NULL)
2574 {
2575 php_error(E_ERROR, "Loading font \"%s\" failed! "
2576 "Please use new SWFBrowserFont(\"%s\") "
2577 "for player/browser fonts.", file, file);
2578
2579 }
2580
2581 if(font)
2582 {
2583 #if PHP_VERSION_ID >= 70000
2584 ret = zend_register_resource(font, le_swffontp);
2585 add_property_resource(getThis(), "font", ret);
2586 #else
2587 object_init_ex(getThis(), font_class_entry_ptr);
2588 ret = zend_list_insert(font, le_swffontp);
2589 add_property_resource(getThis(), "font", ret);
2590 zend_list_addref(ret);
2591 #endif
2592 }
2593 }
2594
2595 #if PHP_VERSION_ID >= 70000
2596 static void destroy_SWFFont_resource(zend_resource *resource)
2597 #else
2598 static void destroy_SWFFont_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
2599 #endif
2600 {
2601 destroySWFBlock((SWFBlock)resource->ptr);
2602 }
2603 /* }}} */
2604
2605 /* {{{ proto float swffont::getWidth(string str)
2606 Calculates the width of the given string in this font at full height */
2607 PHP_METHOD(swffont, getWidth)
2608 {
2609 char *string;
2610 zend_strlen string_len;
2611 float width;
2612
2613 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
2614 return;
2615 }
2616
2617 width = SWFFont_getStringWidth(getFont(getThis() TSRMLS_CC), string);
2618 RETURN_DOUBLE(width);
2619 }
2620 /* }}} */
2621
2622 #ifdef HAVE_NEW_MING
2623 /* {{{ proto int swffont::getUTF8Width(string)
2624 Calculates the width of the given string in this font at full height */
2625
2626 PHP_METHOD(swffont, getUTF8Width)
2627 {
2628 char *string;
2629 zend_strlen string_len;
2630 float width;
2631
2632 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
2633 return;
2634 }
2635
2636 width = SWFFont_getUTF8StringWidth(getFont(getThis() TSRMLS_CC), string);
2637 RETURN_DOUBLE(width);
2638 }
2639
2640 /* {{{ proto int swffont::getglyphcount() */
2641 PHP_METHOD(swffont, getGlyphCount)
2642 {
2643 RETURN_LONG(SWFFont_getGlyphCount(getFont(getThis() TSRMLS_CC)));
2644 }
2645 /* }}} */
2646
2647 /* {{{ proto string swffont::getname() */
2648 PHP_METHOD(swffont, getName)
2649 {
2650 #if PHP_VERSION_ID >= 70000
2651 char *name = SWFFont_getName(getFont(getThis() TSRMLS_CC));
2652 RETURN_STRING(name);
2653 efree(name);
2654 #else
2655 RETURN_STRING(SWFFont_getName(getFont(getThis() TSRMLS_CC)), 0);
2656 #endif
2657 }
2658 /* }}} */
2659 #endif
2660
2661 /* {{{ proto float swffont::getAscent()
2662 Returns the ascent of the font, or 0 if not available */
2663 PHP_METHOD(swffont, getAscent)
2664 {
2665 if (ZEND_NUM_ARGS() != 0) {
2666 WRONG_PARAM_COUNT;
2667 }
2668 RETURN_DOUBLE(SWFFont_getAscent(getFont(getThis() TSRMLS_CC)));
2669 }
2670 /* }}} */
2671
2672 /* {{{ proto float swffont::getDescent()
2673 Returns the descent of the font, or 0 if not available */
2674 PHP_METHOD(swffont, getDescent)
2675 {
2676 if (ZEND_NUM_ARGS() != 0) {
2677 WRONG_PARAM_COUNT;
2678 }
2679 RETURN_DOUBLE(SWFFont_getDescent(getFont(getThis() TSRMLS_CC)));
2680 }
2681 /* }}} */
2682
2683 /* {{{ proto float swffont::getLeading()
2684 Returns the leading of the font, or 0 if not available */
2685 PHP_METHOD(swffont, getLeading)
2686 {
2687 if (ZEND_NUM_ARGS() != 0) {
2688 WRONG_PARAM_COUNT;
2689 }
2690 RETURN_DOUBLE(SWFFont_getLeading(getFont(getThis() TSRMLS_CC)));
2691 }
2692 /* }}} */
2693
2694 /* {{{ proto string swffont::getShape(code)
2695 Returns the glyph shape of a char as a text string */
2696 PHP_METHOD(swffont, getShape)
2697 {
2698 zend_long zcode;
2699 char *result;
2700
2701 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &zcode) == FAILURE)
2702 WRONG_PARAM_COUNT;
2703
2704 result = SWFFont_getShape(getFont(getThis() TSRMLS_CC), zcode);
2705 #if PHP_VERSION_ID >= 70000
2706 RETURN_STRING(result);
2707 #else
2708 RETURN_STRING(result, 1);
2709 #endif
2710 free(result);
2711 }
2712 /* }}} */
2713
2714 static zend_function_entry swffont_functions[] = {
2715 PHP_ME(swffont, __construct, NULL, 0)
2716 PHP_ME(swffont, getWidth, NULL, 0)
2717 #ifdef HAVE_NEW_MING
2718 PHP_ME(swffont, getUTF8Width, NULL, 0)
2719 #endif
2720 PHP_ME(swffont, getAscent, NULL, 0)
2721 PHP_ME(swffont, getDescent, NULL, 0)
2722 PHP_ME(swffont, getLeading, NULL, 0)
2723 #ifdef HAVE_NEW_MING
2724 PHP_ME(swffont, getGlyphCount, NULL, 0)
2725 PHP_ME(swffont, getName, NULL, 0)
2726 #endif
2727 PHP_ME(swffont, getShape, NULL, 0)
2728 { NULL, NULL, NULL }
2729 };
2730
2731 /* }}} */
2732
2733 /* {{{ SWFFilterMatrix
2734 */
2735 /* {{{ proto void swffiltermatrix::__construct(cols, rows, array:vals)
2736 Creates a new SWFFilterMatrix object */
2737 PHP_METHOD(swffiltermatrix, __construct)
2738 {
2739 zend_long cols, rows;
2740 SWFFilterMatrix matrix;
2741 HashTable *arr_hash;
2742 #if PHP_VERSION_ID >= 70000
2743 zval *vals, *data;
2744 zend_resource *ret;
2745 int items, i;
2746 #else
2747 zval *vals, **data;
2748 int ret, items, i;
2749 HashPosition pointer;
2750 #endif
2751 float *values;
2752
2753 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla", &cols, &rows, &vals) == FAILURE) {
2754 return;
2755 }
2756
2757 arr_hash = Z_ARRVAL_P(vals);
2758 items = zend_hash_num_elements(arr_hash);
2759 if(items != cols * rows)
2760 {
2761 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Can't create FilterMatrix."
2762 "Not enough / too many items in array");
2763 }
2764 values = (float *)malloc(items * sizeof(float));
2765 #if PHP_VERSION_ID >= 70000
2766 i=0;
2767 ZEND_HASH_FOREACH_VAL(arr_hash, data)
2768 #else
2769 for(i = 0, zend_hash_internal_pointer_reset_ex(arr_hash, &pointer);
2770 zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS;
2771 zend_hash_move_forward_ex(arr_hash, &pointer), i++)
2772 #endif
2773 {
2774 zval temp;
2775 #if PHP_VERSION_ID >= 70000
2776 temp = *data;
2777 #else
2778 temp = **data;
2779 #endif
2780 zval_copy_ctor(&temp);
2781 convert_to_double(&temp);
2782 values[i] = Z_DVAL(temp);
2783 zval_dtor(&temp);
2784 #if PHP_VERSION_ID >= 70000
2785 i++;
2786 } ZEND_HASH_FOREACH_END();
2787 #else
2788 }
2789 #endif
2790
2791 matrix = newSWFFilterMatrix(cols, rows, values);
2792 free(values); /* array is copied by libming */
2793 #if PHP_VERSION_ID >= 70000
2794 ret = zend_register_resource(matrix, le_swffiltermatrixp);
2795 add_property_resource(getThis(), "filtermatrix", ret);
2796 #else
2797 object_init_ex(getThis(), filtermatrix_class_entry_ptr);
2798 ret = zend_list_insert(matrix, le_swffiltermatrixp);
2799 add_property_resource(getThis(), "filtermatrix", ret);
2800 zend_list_addref(ret);
2801 #endif
2802 }
2803
2804 #if PHP_VERSION_ID >= 70000
destroy_SWFFilterMatrix_resource(zend_resource * resource)2805 static void destroy_SWFFilterMatrix_resource(zend_resource *resource)
2806 #else
2807 static void destroy_SWFFilterMatrix_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
2808 #endif
2809 {
2810 destroySWFFilterMatrix((SWFFilterMatrix)resource->ptr);
2811 }
2812 /* }}} */
2813
2814 /* {{{ internal function getFilterMatrix
2815 Returns the SWFFilterMatrix object contained in zval *id */
getFilterMatrix(zval * id TSRMLS_DC)2816 static SWFFilterMatrix getFilterMatrix(zval *id TSRMLS_DC)
2817 {
2818 void *matrix = SWFgetProperty(id, "filtermatrix", strlen("filtermatrix"), le_swffiltermatrixp TSRMLS_CC);
2819
2820 if (!matrix) {
2821 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFilterMatrix");
2822 }
2823 return (SWFFilterMatrix)matrix;
2824 }
2825 /* }}} */
2826 static zend_function_entry swffiltermatrix_functions[] = {
2827 PHP_ME(swffiltermatrix, __construct, NULL, 0)
2828 { NULL, NULL, NULL }
2829 };
2830 /* }}} */
2831
2832 /* {{{ SWFShadow
2833 */
2834 /* {{{ proto void swfshadow::__construct(angle, distance, strength)
2835 Creates a new SWFShadow object */
PHP_METHOD(swfshadow,__construct)2836 PHP_METHOD(swfshadow, __construct)
2837 {
2838 double angle, distance, strength;
2839 SWFShadow shadow;
2840 #if PHP_VERSION_ID >= 70000
2841 zend_resource *ret;
2842 #else
2843 int ret;
2844 #endif
2845
2846 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &angle, &distance, &strength) == FAILURE) {
2847 return;
2848 }
2849
2850 shadow = newSWFShadow(angle, distance, strength);
2851 #if PHP_VERSION_ID >= 70000
2852 ret = zend_register_resource(shadow, le_swfshadowp);
2853 add_property_resource(getThis(), "shadow", ret);
2854 #else
2855 object_init_ex(getThis(), shadow_class_entry_ptr);
2856 ret = zend_list_insert(shadow, le_swfshadowp);
2857 add_property_resource(getThis(), "shadow", ret);
2858 zend_list_addref(ret);
2859 #endif
2860 }
2861
2862 #if PHP_VERSION_ID >= 70000
destroy_SWFShadow_resource(zend_resource * resource)2863 static void destroy_SWFShadow_resource(zend_resource *resource)
2864 #else
2865 static void destroy_SWFShadow_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
2866 #endif
2867 {
2868 destroySWFShadow((SWFShadow)resource->ptr);
2869 }
2870 /* }}} */
2871
2872 /* {{{ internal function getShadow
2873 Returns the SWFShadow object contained in zval *id */
getShadow(zval * id TSRMLS_DC)2874 static SWFShadow getShadow(zval *id TSRMLS_DC)
2875 {
2876 void *shadow = SWFgetProperty(id, "shadow", strlen("shadow"), le_swfshadowp TSRMLS_CC);
2877
2878 if (!shadow) {
2879 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFShadow");
2880 }
2881 return (SWFShadow)shadow;
2882 }
2883 /* }}} */
2884 static zend_function_entry swfshadow_functions[] = {
2885 PHP_ME(swfshadow, __construct, NULL, 0)
2886 { NULL, NULL, NULL }
2887 };
2888 /* }}} */
2889
2890 /* {{{ SWFBlur
2891 */
2892 /* {{{ proto void swfblur::__construct(blurX, blurY, passes)
2893 Creates a new SWFBlur object */
PHP_METHOD(swfblur,__construct)2894 PHP_METHOD(swfblur, __construct)
2895 {
2896 double blurX, blurY;
2897 zend_long passes;
2898 SWFBlur blur;
2899 #if PHP_VERSION_ID >= 70000
2900 zend_resource *ret;
2901 #else
2902 int ret;
2903 #endif
2904
2905 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddl", &blurX, &blurY, &passes) == FAILURE) {
2906 return;
2907 }
2908
2909 blur = newSWFBlur(blurX, blurY, passes);
2910 #if PHP_VERSION_ID >= 70000
2911 ret = zend_register_resource(blur, le_swfblurp);
2912 add_property_resource(getThis(), "blur", ret);
2913 #else
2914 object_init_ex(getThis(), blur_class_entry_ptr);
2915 ret = zend_list_insert(blur, le_swfblurp);
2916 add_property_resource(getThis(), "blur", ret);
2917 zend_list_addref(ret);
2918 #endif
2919 }
2920
2921 #if PHP_VERSION_ID >= 70000
destroy_SWFBlur_resource(zend_resource * resource)2922 static void destroy_SWFBlur_resource(zend_resource *resource)
2923 #else
2924 static void destroy_SWFBlur_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
2925 #endif
2926 {
2927 destroySWFBlur((SWFBlur)resource->ptr);
2928 }
2929 /* }}} */
2930
2931 /* {{{ internal function getBlur
2932 Returns the SWFBlur object contained in zval *id */
getBlur(zval * id TSRMLS_DC)2933 static SWFBlur getBlur(zval *id TSRMLS_DC)
2934 {
2935 void *blur = SWFgetProperty(id, "blur", strlen("blur"), le_swfblurp TSRMLS_CC);
2936
2937 if (!blur) {
2938 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFBlur");
2939 }
2940 return (SWFBlur)blur;
2941 }
2942 /* }}} */
2943 static zend_function_entry swfblur_functions[] = {
2944 PHP_ME(swfblur, __construct, NULL, 0)
2945 { NULL, NULL, NULL }
2946 };
2947 /* }}} */
2948
2949 /* {{{ SWFGradient
2950 */
2951 /* {{{ proto void swfgradient::__construct()
2952 Creates a new SWFGradient object */
PHP_METHOD(swfgradient,__construct)2953 PHP_METHOD(swfgradient, __construct)
2954 {
2955 SWFGradient gradient = newSWFGradient();
2956 #if PHP_VERSION_ID >= 70000
2957 zend_resource *ret = zend_register_resource(gradient, le_swfgradientp);
2958 add_property_resource(getThis(), "gradient", ret);
2959 #else
2960 int ret = zend_list_insert(gradient, le_swfgradientp);
2961 object_init_ex(getThis(), gradient_class_entry_ptr);
2962 add_property_resource(getThis(), "gradient", ret);
2963 zend_list_addref(ret);
2964 #endif
2965 }
2966
2967 #if PHP_VERSION_ID >= 70000
destroy_SWFGradient_resource(zend_resource * resource)2968 static void destroy_SWFGradient_resource(zend_resource *resource)
2969 #else
2970 static void destroy_SWFGradient_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
2971 #endif
2972 {
2973 destroySWFGradient((SWFGradient)resource->ptr);
2974 }
2975 /* }}} */
2976
2977 /* {{{ internal function getGradient
2978 Returns the SWFGradient object contained in zval *id */
getGradient(zval * id TSRMLS_DC)2979 static SWFGradient getGradient(zval *id TSRMLS_DC)
2980 {
2981 void *gradient = SWFgetProperty(id, "gradient", 8, le_swfgradientp TSRMLS_CC);
2982
2983 if (!gradient) {
2984 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFGradient");
2985 }
2986 return (SWFGradient)gradient;
2987 }
2988 /* }}} */
2989
2990 /* {{{ proto void swfgradient::addEntry(float ratio, int r, int g, int b [, int a])
2991 Adds given entry to the gradient */
PHP_METHOD(swfgradient,addEntry)2992 PHP_METHOD(swfgradient, addEntry)
2993 {
2994 double ratio;
2995 zend_long r, g, b, a = 0xff;
2996
2997 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dlll|l", &ratio, &r, &g, &b, &a) == FAILURE) {
2998 return;
2999 }
3000
3001 SWFGradient_addEntry( getGradient(getThis() TSRMLS_CC), ratio, (byte)r, (byte)g, (byte)b, (byte)a);
3002 }
3003 /* }}} */
3004
3005 /* {{{ proto void swfgradient::setSpreadMode(mode)
3006 supported mode values:
3007 * SWF_GRADIENT_PAD
3008 * SWF_GRADIENT_REFLECT
3009 * SWF_GRADIENT_REPEAT
3010 */
PHP_METHOD(swfgradient,setSpreadMode)3011 PHP_METHOD(swfgradient, setSpreadMode)
3012 {
3013 zend_long val;
3014
3015 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) {
3016 return;
3017 }
3018
3019 SWFGradient_setSpreadMode(getGradient(getThis() TSRMLS_CC), val);
3020 }
3021 /* }}} */
3022
3023 /* {{{ proto void swfgradient::setInterpolationMode(mode)
3024 * supported mode values:
3025 * SWF_GRADIENT_NORMAL
3026 * SWF_GRADIENT_LINEAR
3027 */
PHP_METHOD(swfgradient,setInterpolationMode)3028 PHP_METHOD(swfgradient, setInterpolationMode)
3029 {
3030 zend_long val;
3031
3032 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) {
3033 return;
3034 }
3035
3036 SWFGradient_setInterpolationMode(getGradient(getThis() TSRMLS_CC), val);
3037 }
3038 /* }}} */
3039
3040 /* {{{ proto void swfgradient::setFocalPoint(mode) */
PHP_METHOD(swfgradient,setFocalPoint)3041 PHP_METHOD(swfgradient, setFocalPoint)
3042 {
3043 zend_long val;
3044
3045 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) {
3046 return;
3047 }
3048
3049 SWFGradient_setFocalPoint(getGradient(getThis() TSRMLS_CC), val);
3050 }
3051 /* }}} */
3052
3053 static zend_function_entry swfgradient_functions[] = {
3054 PHP_ME(swfgradient, __construct, NULL, 0)
3055 PHP_ME(swfgradient, addEntry, NULL, 0)
3056 PHP_ME(swfgradient, setSpreadMode, NULL, 0)
3057 PHP_ME(swfgradient, setInterpolationMode, NULL, 0)
3058 PHP_ME(swfgradient, setFocalPoint, NULL, 0)
3059 { NULL, NULL, NULL }
3060 };
3061 /* }}} */
3062
3063 /* {{{ SWFFilter
3064 */
3065
3066 /* helper functions */
3067 #if PHP_VERSION_ID >= 70000
hashToColor(zval * colorHash TSRMLS_DC)3068 static SWFColor hashToColor(zval *colorHash TSRMLS_DC)
3069 {
3070 zval *temp;
3071 zend_string *keyZ;
3072 unsigned long index;
3073 #else
3074 static SWFColor hashToColor(zval **colorHash TSRMLS_DC)
3075 {
3076 zval **data;
3077 HashPosition pointer;
3078 #endif
3079 HashTable *arr_hash;
3080 SWFColor c;
3081
3082 c.alpha = 0xff;
3083 c.red = 0;
3084 c.green = 0;
3085 c.blue = 0;
3086
3087 #if PHP_VERSION_ID >= 70000
3088 arr_hash = Z_ARRVAL_P(colorHash);
3089 #else
3090 arr_hash = Z_ARRVAL_PP(colorHash);
3091 #endif
3092 if(zend_hash_num_elements(arr_hash) < 3 || zend_hash_num_elements(arr_hash) > 4)
3093 php_error_docref(NULL TSRMLS_CC, E_ERROR, "not a valid colorHash\n");
3094
3095 #if PHP_VERSION_ID >= 70000
3096 ZEND_HASH_FOREACH_KEY_VAL(arr_hash, index, keyZ, temp)
3097 {
3098 char *key;
3099 if (keyZ)
3100 {
3101 key = keyZ->val;
3102 if(strcmp(key, "red") == 0)
3103 c.red = zval_get_long(temp);
3104 else if (strcmp(key, "green") == 0)
3105 c.green = zval_get_long(temp);
3106 else if (strcmp(key, "blue") == 0)
3107 c.blue = zval_get_long(temp);
3108 else if (strcmp(key, "alpha") == 0)
3109 c.alpha = zval_get_long(temp);
3110 else
3111 php_error_docref(NULL TSRMLS_CC, E_ERROR, "not a valid colorHash\n");
3112 }
3113 } ZEND_HASH_FOREACH_END();
3114 #else
3115 for(zend_hash_internal_pointer_reset_ex(arr_hash, &pointer);
3116 zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS;
3117 zend_hash_move_forward_ex(arr_hash, &pointer))
3118 {
3119 zval temp;
3120 char *key;
3121 unsigned int key_len;
3122 unsigned long index;
3123
3124 temp = **data;
3125 if (zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer)
3126 == HASH_KEY_IS_STRING)
3127 {
3128 zval_copy_ctor(&temp);
3129 convert_to_long(&temp);
3130 if(strcmp(key, "red") == 0)
3131 c.red = Z_LVAL(temp);
3132 else if (strcmp(key, "green") == 0)
3133 c.green = Z_LVAL(temp);
3134 else if (strcmp(key, "blue") == 0)
3135 c.blue = Z_LVAL(temp);
3136 else if (strcmp(key, "alpha") == 0)
3137 c.alpha = Z_LVAL(temp);
3138 else
3139 php_error_docref(NULL TSRMLS_CC, E_ERROR, "not a valid colorHash\n");
3140
3141 zval_dtor(&temp);
3142 }
3143 }
3144 #endif
3145 return c;
3146 }
3147
3148 #if PHP_VERSION_ID >= 70000
3149 static SWFFilter createDropShadowFilter(zval *colorHash, zval *blur,
3150 zval *shadow, zval *flags)
3151 {
3152 convert_to_array_ex(colorHash);
3153 convert_to_object_ex(blur);
3154 convert_to_object_ex(shadow);
3155 convert_to_long_ex(flags);
3156 return newDropShadowFilter(hashToColor(colorHash), getBlur(blur), getShadow(shadow),
3157 Z_LVAL_P(flags));
3158 #else
3159 static SWFFilter createDropShadowFilter(int argc, zval **argv[] TSRMLS_DC)
3160 {
3161 zval **colorHash, **blur, **shadow, **flags;
3162 SWFColor c;
3163
3164 if(argc != 5)
3165 return NULL;
3166
3167 colorHash = argv[1];
3168 convert_to_array_ex(colorHash);
3169 c = hashToColor(colorHash TSRMLS_CC);
3170
3171 blur = argv[2];
3172 convert_to_object_ex(blur);
3173
3174 shadow = argv[3];
3175 convert_to_object_ex(shadow);
3176
3177 flags = argv[4];
3178 convert_to_long_ex(flags);
3179
3180 return newDropShadowFilter(c, getBlur(*blur TSRMLS_CC),
3181 getShadow(*shadow TSRMLS_CC), Z_LVAL_PP(flags));
3182 #endif
3183 }
3184
3185 #if PHP_VERSION_ID >= 70000
3186 static SWFFilter createBlurFilter(zval *blur)
3187 {
3188 convert_to_object_ex(blur);
3189 return newBlurFilter(getBlur(blur));
3190 #else
3191 static SWFFilter createBlurFilter(int argc, zval **argv[] TSRMLS_DC)
3192 {
3193 zval **blur;
3194
3195 if(argc != 2)
3196 return NULL;
3197
3198 blur = argv[1];
3199
3200 convert_to_object_ex(blur);
3201 return newBlurFilter(getBlur(*blur TSRMLS_CC));
3202 #endif
3203 }
3204
3205 #if PHP_VERSION_ID >= 70000
3206 static SWFFilter createGlowFilter(zval *color, zval *blur, zval *strength,
3207 zval *flags)
3208 {
3209 convert_to_array_ex(color);
3210 convert_to_object_ex(blur);
3211 convert_to_double_ex(strength);
3212 convert_to_long_ex(flags);
3213 return newGlowFilter(hashToColor(color), getBlur(blur),
3214 Z_DVAL_P(strength), Z_LVAL_P(flags));
3215 #else
3216 static SWFFilter createGlowFilter(int argc, zval **argv[] TSRMLS_DC)
3217 {
3218 zval **color, **blur, **strength, **flags;
3219 SWFColor c;
3220
3221 if(argc != 5)
3222 return NULL;
3223
3224 color = argv[1];
3225 convert_to_array_ex(color);
3226 c = hashToColor(color TSRMLS_CC);
3227
3228 blur = argv[2];
3229 convert_to_object_ex(blur);
3230
3231 strength = argv[3];
3232 convert_to_double_ex(strength);
3233
3234 flags = argv[4];
3235 convert_to_long_ex(flags);
3236
3237 return newGlowFilter(c, getBlur(*blur TSRMLS_CC),
3238 Z_DVAL_PP(strength), Z_LVAL_PP(flags));
3239 #endif
3240 }
3241
3242 #if PHP_VERSION_ID >= 70000
3243 static SWFFilter createBevelFilter(zval *sColor, zval *hColor, zval *blur, zval *shadow, zval *flags)
3244 {
3245 convert_to_array_ex(sColor);
3246 convert_to_array_ex(hColor);
3247 convert_to_object_ex(blur);
3248 convert_to_object_ex(shadow);
3249 convert_to_long_ex(flags);
3250 return newBevelFilter(hashToColor(sColor), hashToColor(hColor), getBlur(blur),
3251 getShadow(shadow), Z_LVAL_P(flags));
3252 #else
3253 static SWFFilter createBevelFilter(int argc, zval **argv[] TSRMLS_DC)
3254 {
3255 zval **sColor, **hColor, **blur, **shadow, **flags;
3256 SWFColor hc, sc;
3257
3258 if(argc != 6)
3259 return NULL;
3260
3261 sColor = argv[1];
3262 convert_to_array_ex(sColor);
3263 sc = hashToColor(sColor TSRMLS_CC);
3264
3265 hColor = argv[2];
3266 convert_to_array_ex(hColor);
3267 hc = hashToColor(hColor TSRMLS_CC);
3268
3269 blur = argv[3];
3270 convert_to_object_ex(blur);
3271
3272 shadow = argv[4];
3273 convert_to_object_ex(shadow);
3274
3275 flags = argv[5];
3276 convert_to_long_ex(flags);
3277
3278 return newBevelFilter(sc, hc, getBlur(*blur TSRMLS_CC),
3279 getShadow(*shadow TSRMLS_CC), Z_LVAL_PP(flags));
3280 #endif
3281 }
3282
3283 #if PHP_VERSION_ID >= 70000
3284 static SWFFilter createGradientGlowFilter(zval *gradient, zval *blur, zval *shadow, zval *flags)
3285 {
3286 convert_to_object_ex(gradient);
3287 convert_to_object_ex(blur);
3288 convert_to_object_ex(shadow);
3289 convert_to_long_ex(flags);
3290 return newGradientGlowFilter(getGradient(gradient),
3291 getBlur(blur), getShadow(shadow), Z_LVAL_P(flags));
3292 #else
3293 static SWFFilter createGradientGlowFilter(int argc, zval **argv[] TSRMLS_DC)
3294 {
3295 zval **gradient, **blur, **shadow, **flags;
3296
3297 if(argc != 5)
3298 return NULL;
3299
3300 gradient = argv[1];
3301 convert_to_object_ex(gradient);
3302
3303 blur = argv[2];
3304 convert_to_object_ex(blur);
3305
3306 shadow = argv[3];
3307 convert_to_object_ex(shadow);
3308
3309 flags = argv[4];
3310 convert_to_long_ex(flags);
3311
3312 return newGradientGlowFilter(getGradient(*gradient TSRMLS_CC),
3313 getBlur(*blur TSRMLS_CC), getShadow(*shadow TSRMLS_CC),
3314 Z_LVAL_PP(flags));
3315 #endif
3316 }
3317
3318 #if PHP_VERSION_ID >= 70000
3319 static SWFFilter createConvolutionFilter(zval *matrix, zval *div, zval *bias, zval *color, zval *flags)
3320 {
3321 convert_to_object_ex(matrix);
3322 convert_to_double_ex(div);
3323 convert_to_double_ex(bias);
3324 convert_to_array_ex(color);
3325 convert_to_long_ex(flags);
3326 return newConvolutionFilter(getFilterMatrix(matrix), Z_DVAL_P(div),
3327 Z_DVAL_P(bias), hashToColor(color), Z_LVAL_P(flags));
3328 #else
3329 static SWFFilter createConvolutionFilter(int argc, zval **argv[] TSRMLS_DC)
3330 {
3331 zval **matrix, **div, **bias, **color, **flags;
3332 SWFColor c;
3333
3334 if(argc != 6)
3335 return NULL;
3336
3337 matrix = argv[1];
3338 convert_to_object_ex(matrix);
3339
3340 div = argv[2];
3341 convert_to_double_ex(div);
3342
3343 bias = argv[3];
3344 convert_to_double_ex(bias);
3345
3346 color = argv[4];
3347 convert_to_array_ex(color);
3348 c = hashToColor(color TSRMLS_CC);
3349
3350 flags = argv[5];
3351 convert_to_long_ex(flags);
3352
3353 return newConvolutionFilter(getFilterMatrix(*matrix TSRMLS_CC), Z_DVAL_PP(div),
3354 Z_DVAL_PP(bias), c, Z_LVAL_PP(flags));
3355 #endif
3356 }
3357
3358 #if PHP_VERSION_ID >= 70000
3359 static SWFFilter createColorMatrixFilter(zval *matrix)
3360 {
3361 convert_to_object_ex(matrix);
3362 return newColorMatrixFilter(getFilterMatrix(matrix));
3363 #else
3364 static SWFFilter createColorMatrixFilter(int argc, zval **argv[] TSRMLS_DC)
3365 {
3366 zval **matrix;
3367
3368 if(argc != 2)
3369 return NULL;
3370
3371 matrix = argv[1];
3372 convert_to_object_ex(matrix);
3373
3374 return newColorMatrixFilter(getFilterMatrix(*matrix TSRMLS_CC));
3375 #endif
3376 }
3377
3378 #if PHP_VERSION_ID >= 70000
3379 static SWFFilter createGradientBevelFilter(zval *gradient, zval *blur, zval *shadow, zval *flags)
3380 {
3381 convert_to_object_ex(gradient);
3382 convert_to_object_ex(blur);
3383 convert_to_object_ex(shadow);
3384 convert_to_long_ex(flags);
3385 return newGradientBevelFilter(getGradient(gradient),
3386 getBlur(blur), getShadow(shadow),
3387 Z_LVAL_P(flags));
3388 #else
3389 static SWFFilter createGradientBevelFilter(int argc, zval **argv[] TSRMLS_DC)
3390 {
3391 zval **gradient, **blur, **shadow, **flags;
3392
3393 if(argc != 5)
3394 return NULL;
3395
3396 gradient = argv[1];
3397 convert_to_object_ex(gradient);
3398
3399 blur = argv[2];
3400 convert_to_object_ex(blur);
3401
3402 shadow = argv[3];
3403 convert_to_object_ex(shadow);
3404
3405 flags = argv[4];
3406 convert_to_long_ex(flags);
3407
3408 return newGradientBevelFilter(getGradient(*gradient TSRMLS_CC),
3409 getBlur(*blur TSRMLS_CC), getShadow(*shadow TSRMLS_CC),
3410 Z_LVAL_PP(flags));
3411 #endif
3412 }
3413
3414 /* {{{ proto void swffilter::__construct(type, ...)
3415 Creates a new SWFFilter object:
3416
3417 Supported filter types:
3418 * SWFFILTER_TYPE_DROPSHADOW
3419 new SWFFilter(SWFFILTER_TYPE_DROPSHADOW, colorHash, blur, shadow, flags);
3420 * SWFFILTER_TYPE_BLUR
3421 new SWFFilter(SWFFILTER_TYPE_BLUR, blur);
3422 * SWFFILTER_TYPE_GLOW
3423 new SWFFilter(SWFFILTER_TYPE_GLOW, colorHash, blur, strenght:float, flags);
3424 * SWFFILTER_TYPE_BEVEL
3425 new SWFFilter(SWFFILTER_TYPE_BEVEL, colorHash_shadow, colorHash_highlight, blur, shadow, flags);
3426 * SWFFILTER_TYPE_GRADIENTGLOW
3427 new SWFFilter(SWFFILTER_TYPE_GRADIENTGLOW, gradient, blur, shadow, flags);
3428 * SWFFILTER_TYPE_CONVOLUTION
3429 new SWFFilter(SWFFILTER_TYPE_CONVOLUTION, filterMatrix, divisor:float, bias:float, colorHash, flags);
3430 * SWFFILTER_TYPE_COLORMATRIX
3431 new SWFFilter(SWFFILTER_TYPE_COLORMATRIX, filterMatrix);
3432 * SWFFILTER_TYPE_GRADIENTBEVEL
3433 new SWFFilter(SWFFILTER_TYPE_GRADIENTBEVEL, gradient, blur, shadow, flags);
3434
3435 Supported flags are:
3436 * SWFFILTER_FLAG_CLAMP
3437 * SWFFILTER_FLAG_PRESERVE_ALPHA
3438 * SWFFILTER_MODE_INNER
3439 * SWFFILTER_MODE_KO
3440
3441 A colorHash must have the following entries:
3442 'red' => 0...255,
3443 'green' => 0...255,
3444 'blue' => 0...255,
3445 'alpha' => 0...255 (optional)
3446 */
3447 PHP_METHOD(swffilter, __construct)
3448 {
3449 SWFFilter filter = NULL;
3450 #if PHP_VERSION_ID >= 70000
3451 zval *argv;
3452 int argc;
3453 int type;
3454 zend_resource *ret;
3455
3456 if (zend_parse_parameters(ZEND_NUM_ARGS(), "*", &argv, &argc) == FAILURE || argc > 6 || argc < 2)
3457 WRONG_PARAM_COUNT
3458 type = zval_get_long(&argv[0]);
3459 switch(type)
3460 {
3461 case SWFFILTER_TYPE_DROPSHADOW:
3462 if (argc != 5)
3463 WRONG_PARAM_COUNT
3464 filter = createDropShadowFilter(&argv[1], &argv[2], &argv[3], &argv[4]);
3465 break;
3466 case SWFFILTER_TYPE_BLUR:
3467 if (argc != 2)
3468 WRONG_PARAM_COUNT
3469 filter = createBlurFilter(&argv[1]);
3470 break;
3471 case SWFFILTER_TYPE_GLOW:
3472 if (argc != 5)
3473 WRONG_PARAM_COUNT
3474 filter = createGlowFilter(&argv[1], &argv[2], &argv[3], &argv[4]);
3475 break;
3476 case SWFFILTER_TYPE_BEVEL:
3477 if (argc != 6)
3478 WRONG_PARAM_COUNT
3479 filter = createBevelFilter(&argv[1], &argv[2], &argv[3], &argv[4], &argv[5]);
3480 break;
3481 case SWFFILTER_TYPE_GRADIENTGLOW:
3482 if (argc != 5)
3483 WRONG_PARAM_COUNT
3484 filter = createGradientGlowFilter(&argv[1], &argv[2], &argv[3], &argv[4]);
3485 break;
3486 case SWFFILTER_TYPE_CONVOLUTION:
3487 if (argc != 6)
3488 WRONG_PARAM_COUNT
3489 filter = createConvolutionFilter(&argv[1], &argv[2], &argv[3], &argv[4], &argv[5]);
3490 break;
3491 case SWFFILTER_TYPE_COLORMATRIX:
3492 if (argc != 2)
3493 WRONG_PARAM_COUNT
3494 filter = createColorMatrixFilter(&argv[1]);
3495 break;
3496 case SWFFILTER_TYPE_GRADIENTBEVEL:
3497 if (argc != 5)
3498 WRONG_PARAM_COUNT
3499 filter = createGradientBevelFilter(&argv[1], &argv[2], &argv[3], &argv[4]);
3500 break;
3501 default:
3502 php_error_docref(NULL, E_ERROR, "new SWFFilter: unknown type");
3503 }
3504 if(filter == NULL)
3505 WRONG_PARAM_COUNT;
3506 ret = zend_register_resource(filter, le_swffilterp);
3507 add_property_resource(getThis(), "filter", ret);
3508 #else
3509 zval **argv[6];
3510 int argc = ZEND_NUM_ARGS();
3511 int type, ret;
3512 if (argc > 6 || argc < 2 || zend_get_parameters_array_ex(argc, argv) == FAILURE)
3513 WRONG_PARAM_COUNT;
3514
3515 convert_to_long_ex(argv[0]);
3516 type = Z_LVAL_PP(argv[0]);
3517 switch(type)
3518 {
3519 case SWFFILTER_TYPE_DROPSHADOW:
3520 filter = createDropShadowFilter(argc, argv TSRMLS_CC);
3521 break;
3522 case SWFFILTER_TYPE_BLUR:
3523 filter = createBlurFilter(argc, argv TSRMLS_CC);
3524 break;
3525 case SWFFILTER_TYPE_GLOW:
3526 filter = createGlowFilter(argc, argv TSRMLS_CC);
3527 break;
3528 case SWFFILTER_TYPE_BEVEL:
3529 filter = createBevelFilter(argc, argv TSRMLS_CC);
3530 break;
3531 case SWFFILTER_TYPE_GRADIENTGLOW:
3532 filter = createGradientGlowFilter(argc, argv TSRMLS_CC);
3533 break;
3534 case SWFFILTER_TYPE_CONVOLUTION:
3535 filter = createConvolutionFilter(argc, argv TSRMLS_CC);
3536 break;
3537 case SWFFILTER_TYPE_COLORMATRIX:
3538 filter = createColorMatrixFilter(argc, argv TSRMLS_CC);
3539 break;
3540 case SWFFILTER_TYPE_GRADIENTBEVEL:
3541 filter = createGradientBevelFilter(argc, &argv TSRMLS_CC);
3542 break;
3543 default:
3544 php_error_docref(NULL TSRMLS_CC, E_ERROR, "new SWFFilter: unknown type");
3545 }
3546 object_init_ex(getThis(), filter_class_entry_ptr);
3547 ret = zend_list_insert(filter, le_swffilterp);
3548 add_property_resource(getThis(), "filter", ret);
3549 zend_list_addref(ret);
3550 #endif
3551 }
3552 /* }}} */
3553
3554 /* {{{ internal function getFilter
3555 Returns the SWFFilter object contained in zval *id */
3556 static SWFFilter getFilter(zval *id TSRMLS_DC)
3557 {
3558 void *filter = SWFgetProperty(id, "filter",
3559 strlen("filter"), le_swffilterp TSRMLS_CC);
3560
3561 if (!filter) {
3562 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFilter");
3563 }
3564 return (SWFFilter)filter;
3565 }
3566 /* }}} */
3567
3568 #if PHP_VERSION_ID >= 70000
3569 static void destroy_SWFFilter_resource(zend_resource *resource)
3570 #else
3571 static void destroy_SWFFilter_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
3572 #endif
3573 {
3574 destroySWFFilter((SWFFilter)resource->ptr);
3575 }
3576
3577 static zend_function_entry swffilter_functions[] = {
3578 PHP_ME(swffilter, __construct, NULL, 0)
3579 { NULL, NULL, NULL }
3580 };
3581 /* }}} */
3582
3583 /* {{{ SWFMorph
3584 */
3585 /* {{{ proto void swfmorph::__construct()
3586 Creates a new SWFMorph object */
3587 PHP_METHOD(swfmorph, __construct)
3588 {
3589 SWFMorph morph = newSWFMorphShape();
3590 #if PHP_VERSION_ID >= 70000
3591 zend_resource *ret = zend_register_resource(morph, le_swfmorphp);
3592 add_property_resource(getThis(), "morph", ret);
3593 #else
3594 int ret = zend_list_insert(morph, le_swfmorphp);
3595 object_init_ex(getThis(), morph_class_entry_ptr);
3596 add_property_resource(getThis(), "morph", ret);
3597 zend_list_addref(ret);
3598 #endif
3599 }
3600
3601 #if PHP_VERSION_ID >= 70000
3602 static void destroy_SWFMorph_resource(zend_resource *resource)
3603 #else
3604 static void destroy_SWFMorph_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
3605 #endif
3606 {
3607 destroySWFMorph((SWFMorph)resource->ptr);
3608 }
3609 /* }}} */
3610
3611 /* {{{ internal function getMorph
3612 Returns the SWFMorph object contained in zval *id */
3613 static SWFMorph getMorph(zval *id TSRMLS_DC)
3614 {
3615 void *morph = SWFgetProperty(id, "morph", 5, le_swfmorphp TSRMLS_CC);
3616
3617 if (!morph) {
3618 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMorph");
3619 }
3620 return (SWFMorph)morph;
3621 }
3622 /* }}} */
3623
3624 /* {{{ proto object swfmorph::getShape1()
3625 Return's this SWFMorph's start shape object */
3626 PHP_METHOD(swfmorph, getShape1)
3627 {
3628 #if PHP_VERSION_ID >= 70000
3629 SWFMorph morph = getMorph(getThis());
3630 SWFShape shape = SWFMorph_getShape1(morph);
3631 zend_resource *ret = zend_register_resource(shape, le_swfshapep);
3632 object_init_ex(return_value, shape_class_entry_ptr);
3633 add_property_resource(return_value, "shape", ret);
3634 ret->gc.refcount++;
3635 #else
3636 SWFMorph morph = getMorph(getThis() TSRMLS_CC);
3637 SWFShape shape = SWFMorph_getShape1(morph);
3638 int ret = zend_list_insert(shape, le_swfshapep);
3639 object_init_ex(return_value, shape_class_entry_ptr);
3640 add_property_resource(return_value, "shape", ret);
3641 zend_list_addref(ret);
3642 #endif
3643 }
3644 /* }}} */
3645
3646 /* {{{ proto object swfmorph::getShape2()
3647 Return's this SWFMorph's start shape object */
3648 PHP_METHOD(swfmorph, getShape2)
3649 {
3650 #if PHP_VERSION_ID >= 70000
3651 SWFMorph morph = getMorph(getThis());
3652 SWFShape shape = SWFMorph_getShape2(morph);
3653 zend_resource *ret = zend_register_resource(shape, le_swfshapep);
3654 object_init_ex(return_value, shape_class_entry_ptr);
3655 add_property_resource(return_value, "shape", ret);
3656 ret->gc.refcount++;
3657 #else
3658 SWFMorph morph = getMorph(getThis() TSRMLS_CC);
3659 SWFShape shape = SWFMorph_getShape2(morph);
3660 int ret = zend_list_insert(shape, le_swfshapep);
3661 object_init_ex(return_value, shape_class_entry_ptr);
3662 add_property_resource(return_value, "shape", ret);
3663 zend_list_addref(ret);
3664 #endif
3665 }
3666 /* }}} */
3667
3668 static zend_function_entry swfmorph_functions[] = {
3669 PHP_ME(swfmorph, __construct, NULL, 0)
3670 PHP_ME(swfmorph, getShape1, NULL, 0)
3671 PHP_ME(swfmorph, getShape2, NULL, 0)
3672 { NULL, NULL, NULL }
3673 };
3674
3675 /* }}} */
3676
3677 /* {{{ SWFSoundStream
3678 */
3679
3680 /* {{{ proto class soundstream::init(file) */
3681 PHP_METHOD(swfsoundstream, __construct)
3682 {
3683 zval *zfile;
3684 SWFSoundStream sound = NULL;
3685 SWFInput input = NULL;
3686 #if PHP_VERSION_ID >= 70000
3687 zend_resource *ret;
3688 #else
3689 int ret;
3690 #endif
3691
3692 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zfile) == FAILURE) {
3693 return;
3694 }
3695
3696 switch(Z_TYPE_P(zfile))
3697 {
3698 case IS_RESOURCE:
3699 input = getInput_fromFileResource(zfile TSRMLS_CC);
3700 break;
3701 case IS_OBJECT:
3702 input = getInput(zfile TSRMLS_CC);
3703 break;
3704 case IS_STRING:
3705 input = newSWFInput_filename(Z_STRVAL_P(zfile));
3706 if(input == NULL)
3707 php_error(E_ERROR, "opening sound file failed");
3708 #if PHP_VERSION_ID >= 70000
3709 zend_register_resource(input, le_swfinputp);
3710 #else
3711 zend_list_addref(zend_list_insert(input, le_swfinputp));
3712 #endif
3713 break;
3714
3715 default:
3716 php_error(E_ERROR, "soundstream::init: need either a filename, "
3717 "a file ressource or SWFInput buffer.");
3718 }
3719
3720 sound = newSWFSoundStream_fromInput(input);
3721
3722 if(sound) {
3723 #if PHP_VERSION_ID >= 70000
3724 ret = zend_register_resource(sound, le_swfsoundstreamp);
3725 add_property_resource(getThis(), "soundstream", ret);
3726 #else
3727 object_init_ex(getThis(), soundstream_class_entry_ptr);
3728 ret = zend_list_insert(sound, le_swfsoundstreamp);
3729 add_property_resource(getThis(), "soundstream", ret);
3730 zend_list_addref(ret);
3731 #endif
3732 }
3733 }
3734 /* }}} */
3735
3736 /* {{{ internal function getSoundStream
3737 Returns the SWFSoundStream object contained in zval *id */
3738 static SWFSoundStream getSoundStream(zval *id TSRMLS_DC)
3739 {
3740 void *sound = SWFgetProperty(id, "soundstream", strlen("soundstream"),
3741 le_swfsoundstreamp TSRMLS_CC);
3742 if(!sound)
3743 php_error(E_ERROR, "called object is not an SWFSoundStream!");
3744 return (SWFSoundStream)sound;
3745 }
3746 /* }}} */
3747
3748 /* {{{ internal function destroy_SWFSoundStream */
3749 #if PHP_VERSION_ID >= 70000
3750 static void destroy_SWFSoundStream_resource(zend_resource *resource)
3751 #else
3752 static void destroy_SWFSoundStream_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
3753 #endif
3754 {
3755 destroySWFSoundStream((SWFSoundStream)resource->ptr);
3756 }
3757 /* }}} */
3758
3759 /* {{{
3760 returns the duration of the sound stream */
3761 PHP_METHOD(swfsoundstream, getDuration)
3762 {
3763 if (ZEND_NUM_ARGS() != 0) {
3764 WRONG_PARAM_COUNT;
3765 }
3766
3767 RETURN_LONG(SWFSoundStream_getDuration(getSoundStream(getThis() TSRMLS_CC)));
3768 }
3769 /* }}} */
3770
3771 /* {{{ set initial mp3 delay seek */
3772 PHP_METHOD(swfsoundstream, setInitialMp3Delay)
3773 {
3774 zend_long delay;
3775 SWFSoundStream stream = getSoundStream(getThis() TSRMLS_CC);
3776
3777 if ( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &delay) == FAILURE )
3778 {
3779 return;
3780 }
3781
3782 SWFSoundStream_setInitialMp3Delay(stream, delay);
3783 }
3784 /* }}} */
3785
3786
3787 static zend_function_entry swfsoundstream_functions[] = {
3788 PHP_ME(swfsoundstream, __construct, NULL, 0)
3789 PHP_ME(swfsoundstream, getDuration, NULL, 0)
3790 PHP_ME(swfsoundstream, setInitialMp3Delay, NULL, 0)
3791 { NULL, NULL, NULL }
3792 };
3793 /* }}} */
3794
3795 /* {{{ SWFSound */
3796 /* {{{ internal function SWFSound getSound(zval *id)
3797 Returns the Sound object in zval *id */
3798
3799 SWFSound getSound(zval *id TSRMLS_DC)
3800 {
3801 void *sound = SWFgetProperty(id, "sound", 5, le_swfsoundp TSRMLS_CC);
3802
3803 if(!sound)
3804 php_error(E_ERROR, "called object is not an SWFSound!");
3805
3806 return (SWFSound)sound;
3807 }
3808
3809 /* }}} */
3810 /* {{{ proto void swfsound::__construct(string filename/SWFInput/SWFSoundstream[, int flags])
3811 Creates a new SWFSound object from given file
3812 Takes either a Filename or SWFInput memory buffer AND flags or
3813 a SWFSoundStream object with NO flags.
3814 */
3815 PHP_METHOD(swfsound, __construct)
3816 {
3817 zval *zfile;
3818 zend_long flags;
3819 SWFSound sound = NULL;
3820 SWFInput input = NULL;
3821 SWFSoundStream stream;
3822 #if PHP_VERSION_ID >= 70000
3823 zend_resource *ret;
3824 #else
3825 int ret;
3826 #endif
3827
3828 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &zfile, &flags) == FAILURE) {
3829 return;
3830 }
3831
3832 if(ZEND_NUM_ARGS() == 1)
3833 {
3834 stream = getSoundStream(zfile TSRMLS_CC);
3835 sound = newSWFSound_fromSoundStream(stream);
3836 }
3837 else if(ZEND_NUM_ARGS() == 2)
3838 {
3839 switch(Z_TYPE_P(zfile))
3840 {
3841 case IS_RESOURCE:
3842 input = getInput_fromFileResource(zfile TSRMLS_CC);
3843 break;
3844 case IS_OBJECT:
3845 input = getInput(zfile TSRMLS_CC);
3846 break;
3847 case IS_STRING:
3848 input = newSWFInput_filename(Z_STRVAL_P(zfile));
3849 if(input == NULL)
3850 php_error(E_ERROR, "opening sound file failed");
3851 #if PHP_VERSION_ID >= 70000
3852 zend_register_resource(input, le_swfinputp);
3853 #else
3854 zend_list_addref(zend_list_insert(input, le_swfinputp));
3855 #endif
3856 break;
3857
3858 default:
3859 php_error(E_ERROR, "swfsound::__construct: need either a filename, "
3860 "a file ressource or SWFInput buffer.");
3861 }
3862 sound = newSWFSound_fromInput(input, flags);
3863 }
3864
3865 if(sound != NULL)
3866 {
3867 #if PHP_VERSION_ID >= 70000
3868 ret = zend_register_resource(sound, le_swfsoundp);
3869 add_property_resource(getThis(), "sound", ret);
3870 #else
3871 object_init_ex(getThis(), sound_class_entry_ptr);
3872 ret = zend_list_insert(sound, le_swfsoundp);
3873 add_property_resource(getThis(), "sound", ret);
3874 zend_list_addref(ret);
3875 #endif
3876 }
3877 }
3878
3879 #if PHP_VERSION_ID >= 70000
3880 static void destroy_SWFSound_resource(zend_resource *resource)
3881 #else
3882 static void destroy_SWFSound_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
3883 #endif
3884 {
3885 destroySWFBlock((SWFBlock)resource->ptr);
3886 }
3887
3888 /* }}} */
3889
3890 static zend_function_entry swfsound_functions[] = {
3891 PHP_ME(swfsound, __construct, NULL, 0)
3892 { NULL, NULL, NULL }
3893 };
3894
3895 /* }}} */
3896
3897 #ifdef HAVE_NEW_MING
3898 /* should handle envelope functions */
3899 /* {{{ internal function SWFSoundInstance getSoundInstance(zval *id)
3900 Returns the SoundInstance object in zval *id */
3901
3902 SWFSoundInstance getSoundInstance(zval *id TSRMLS_DC)
3903 {
3904 void *inst = SWFgetProperty(id, "soundinstance", 13, le_swfsoundinstancep TSRMLS_CC);
3905
3906 if (!inst)
3907 php_error(E_ERROR, "called object is not an SWFSoundInstance!");
3908
3909 return (SWFSoundInstance)inst;
3910 }
3911 /* }}} */
3912
3913 /* {{{ swfsoundinstance_nomultiple */
3914
3915 PHP_METHOD(swfsoundinstance, noMultiple)
3916 {
3917 SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC);
3918
3919 if(ZEND_NUM_ARGS() != 0)
3920 WRONG_PARAM_COUNT;
3921
3922 SWFSoundInstance_setNoMultiple(inst);
3923 }
3924 /* }}} */
3925
3926 /* {{{ swfsoundinstance_loopinpoint(point) */
3927
3928 PHP_METHOD(swfsoundinstance, loopInPoint)
3929 {
3930 zend_long point;
3931
3932 SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC);
3933
3934 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &point) == FAILURE) {
3935 return;
3936 }
3937
3938 SWFSoundInstance_setLoopInPoint(inst, point);
3939 }
3940
3941 /* }}} */
3942
3943 /* {{{ swfsoundinstance_loopoutpoint(point) */
3944
3945 PHP_METHOD(swfsoundinstance, loopOutPoint)
3946 {
3947 zend_long point;
3948
3949 SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC);
3950
3951 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &point) == FAILURE) {
3952 return;
3953 }
3954
3955 SWFSoundInstance_setLoopOutPoint(inst, point);
3956 }
3957 /* }}} */
3958
3959 /* {{{ swfsoundinstance_loopcount(point) */
3960
3961 PHP_METHOD(swfsoundinstance, loopCount)
3962 {
3963 zend_long count;
3964 SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC);
3965
3966 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &count) == FAILURE) {
3967 return;
3968 }
3969
3970 SWFSoundInstance_setLoopCount(inst, count);
3971 }
3972 /* }}} */
3973
3974 static zend_function_entry swfsoundinstance_functions[] = {
3975 PHP_ME(swfsoundinstance, noMultiple, NULL, 0)
3976 PHP_ME(swfsoundinstance, loopInPoint, NULL, 0)
3977 PHP_ME(swfsoundinstance, loopOutPoint, NULL, 0)
3978 PHP_ME(swfsoundinstance, loopCount, NULL, 0)
3979 { NULL, NULL, NULL }
3980 };
3981
3982 /* {{{ SWFVideoStream */
3983
3984 /* {{{ proto class swfvideostream_init([filename])
3985 Returns a SWVideoStream object */
3986 PHP_METHOD(swfvideostream, __construct)
3987 {
3988 zval *zfile = NULL;
3989 SWFVideoStream stream;
3990 SWFInput input = NULL;
3991 #if PHP_VERSION_ID >= 70000
3992 zend_resource *ret;
3993 #else
3994 int ret;
3995 #endif
3996
3997 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &zfile) == FAILURE) {
3998 return;
3999 }
4000 switch(ZEND_NUM_ARGS())
4001 {
4002 case 1:
4003
4004 switch(Z_TYPE_P(zfile))
4005 {
4006 case IS_RESOURCE:
4007 input = getInput_fromFileResource(zfile TSRMLS_CC);
4008 break;
4009 case IS_OBJECT:
4010 input = getInput(zfile TSRMLS_CC);
4011 break;
4012 case IS_STRING:
4013 input = newSWFInput_filename(Z_STRVAL_P(zfile));
4014 if(input == NULL)
4015 php_error(E_ERROR, "opening sound video failed");
4016 #if PHP_VERSION_ID >= 70000
4017 zend_register_resource(input, le_swfinputp);
4018 #else
4019 zend_list_addref(zend_list_insert(input, le_swfinputp));
4020 #endif
4021 break;
4022
4023 default:
4024 php_error(E_ERROR, "swfvideostream_init: need either a filename, "
4025 "a file ressource or SWFInput buffer.");
4026 }
4027 stream = newSWFVideoStream_fromInput(input);
4028 break;
4029 case 0:
4030 stream = newSWFVideoStream();
4031 break;
4032 default: /* warn */
4033 return;
4034 }
4035
4036 if(stream) {
4037 #if PHP_VERSION_ID >= 70000
4038 ret = zend_register_resource(stream, le_swfvideostreamp);
4039 add_property_resource(getThis(), "videostream", ret);
4040 #else
4041 object_init_ex(getThis(), videostream_class_entry_ptr);
4042 ret = zend_list_insert(stream, le_swfvideostreamp);
4043 add_property_resource(getThis(), "videostream", ret);
4044 zend_list_addref(ret);
4045 #endif
4046 }
4047 }
4048
4049 #if PHP_VERSION_ID >= 70000
4050 static void destroy_SWFVideoStream_resource(zend_resource *resource)
4051 #else
4052 static void destroy_SWFVideoStream_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
4053 #endif
4054 {
4055 destroySWFVideoStream((SWFVideoStream)resource->ptr);
4056 }
4057 /* }}} */
4058
4059 /* {{{ internal function getVideoStream
4060 Returns the SWFVideoStream object contained in zval *id */
4061 static SWFVideoStream getVideoStream(zval *id TSRMLS_DC)
4062 {
4063 void *stream = SWFgetProperty(id, "videostream", 11, le_swfvideostreamp TSRMLS_CC);
4064 if(!stream)
4065 php_error(E_ERROR, "called object is not an SWFVideoStream!");
4066 return (SWFVideoStream)stream;
4067 }
4068
4069 /* }}} */
4070
4071 /* {{{ setDimension */
4072
4073 PHP_METHOD(swfvideostream, setdimension)
4074 {
4075 zend_long x, y;
4076 SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC);
4077 if(!stream)
4078 php_error(E_ERROR, "getVideoStream returned NULL");
4079
4080 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &x, &y) == FAILURE) {
4081 return;
4082 }
4083
4084 SWFVideoStream_setDimension(stream, x, y);
4085 }
4086 /* }}} */
4087
4088 /* {{{ getNumFrames */
4089 PHP_METHOD(swfvideostream, getnumframes)
4090 {
4091 if (ZEND_NUM_ARGS() != 0) {
4092 WRONG_PARAM_COUNT;
4093 }
4094
4095 RETURN_LONG(SWFVideoStream_getNumFrames(getVideoStream(getThis() TSRMLS_CC)));
4096 }
4097 /* }}} */
4098
4099 /* {{{ hasAudio */
4100 PHP_METHOD(swfvideostream, hasaudio)
4101 {
4102 if (ZEND_NUM_ARGS() != 0) {
4103 WRONG_PARAM_COUNT;
4104 }
4105
4106 RETURN_LONG(SWFVideoStream_hasAudio(getVideoStream(getThis() TSRMLS_CC)));
4107 }
4108 /* }}} */
4109
4110 #if HAVE_SWFVIDEOSTREAM_NEXTFRAME
4111 /* {{{ proto swfvideostream::nextFrame */
4112 PHP_METHOD(swfvideostream, nextFrame)
4113 {
4114 if (ZEND_NUM_ARGS() != 0) {
4115 WRONG_PARAM_COUNT;
4116 }
4117
4118 RETURN_LONG(SWFVideoStream_nextFrame(getVideoStream(getThis() TSRMLS_CC)));
4119 }
4120 /* }}} */
4121 #endif
4122
4123 #if HAVE_SWFVIDEOSTREAM_SETFRAMEMODE
4124 /* {{{ proto swfvideostream::setFrameMode */
4125 PHP_METHOD(swfvideostream, setFrameMode)
4126 {
4127 zend_long mode;
4128 SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC);
4129 if(!stream)
4130 php_error(E_ERROR, "getVideoStream returned NULL");
4131
4132 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) {
4133 return;
4134 }
4135
4136 RETURN_LONG(SWFVideoStream_setFrameMode(stream, mode));
4137 }
4138 /* }}} */
4139 #endif
4140
4141 #if HAVE_SWFVIDEOSTREAM_SEEK
4142 /* {{{ proto swfvideostream::seek(frame, whence) */
4143 PHP_METHOD(swfvideostream, seek)
4144 {
4145 zend_long frame, whence;
4146 SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC);
4147 if(!stream)
4148 php_error(E_ERROR, "getVideoStream returned NULL");
4149
4150 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &frame, &whence) == FAILURE) {
4151 return;
4152 }
4153
4154 RETURN_LONG(SWFVideoStream_seek(stream, frame, whence));
4155 }
4156 /* }}} */
4157 #endif
4158
4159 static zend_function_entry swfvideostream_functions[] = {
4160 PHP_ME(swfvideostream, __construct, NULL, 0)
4161 PHP_ME(swfvideostream, setdimension, NULL, 0)
4162 PHP_ME(swfvideostream, getnumframes, NULL, 0)
4163 PHP_ME(swfvideostream, hasaudio, NULL, 0)
4164 #if HAVE_SWFVIDEOSTREAM_SETFRAMEMODE
4165 PHP_ME(swfvideostream, setFrameMode, NULL, 0)
4166 #endif
4167 #if HAVE_SWFVIDEOSTREAM_NEXTFRAME
4168 PHP_ME(swfvideostream, nextFrame, NULL, 0)
4169 #endif
4170 #if HAVE_SWFVIDEOSTREAM_SEEK
4171 PHP_ME(swfvideostream, seek, NULL, 0)
4172 #endif
4173 { NULL, NULL, NULL }
4174 };
4175
4176 /* }}} */
4177
4178 /* {{{ SWFBinaryData
4179 */
4180
4181 /* {{{ proto class swfbinarydata_init(string)
4182 Returns a SWFBinaryData object */
4183 PHP_METHOD(swfbinarydata, __construct)
4184 {
4185 char *data;
4186 zend_strlen data_len;
4187 SWFBinaryData bd = NULL;
4188 #if PHP_VERSION_ID >= 70000
4189 zend_resource *ret;
4190 #else
4191 int ret;
4192 #endif
4193
4194 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) {
4195 return;
4196 }
4197 bd = newSWFBinaryData((unsigned char *)data, data_len);
4198
4199 if(bd) {
4200 #if PHP_VERSION_ID >= 70000
4201 ret = zend_register_resource(bd, le_swfbinarydatap);
4202 add_property_resource(getThis(), "binarydata", ret);
4203 #else
4204 object_init_ex(getThis(), binarydata_class_entry_ptr);
4205 ret = zend_list_insert(bd, le_swfbinarydatap);
4206 add_property_resource(getThis(), "binarydata", ret);
4207 zend_list_addref(ret);
4208 #endif
4209 }
4210 }
4211 /* }}} */
4212
4213 /* {{{ internal function getBinaryData
4214 Returns the SWFBinaryData object contained in zval *id */
4215 static inline SWFBinaryData getBinaryData(zval *id TSRMLS_DC)
4216 {
4217 void *bd = SWFgetProperty(id, "binarydata", strlen("binarydata"), le_swfbinarydatap TSRMLS_CC);
4218 if(!bd)
4219 php_error(E_ERROR, "called object is not an SWFBinaryData!");
4220 return (SWFBinaryData)bd;
4221 }
4222 /* }}} */
4223
4224 /* {{{ internal function destroy_SWFBinaryData */
4225 #if PHP_VERSION_ID >= 70000
4226 static void destroy_SWFBinaryData_resource(zend_resource *resource)
4227 #else
4228 static void destroy_SWFBinaryData_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
4229 #endif
4230 {
4231 destroySWFBinaryData((SWFBinaryData)resource->ptr);
4232 }
4233 /* }}} */
4234
4235 static zend_function_entry swfbinarydata_functions[] = {
4236 PHP_ME(swfbinarydata, __construct, NULL, 0)
4237 { NULL, NULL, NULL }
4238 };
4239 /* }}} */
4240
4241 /* {{{ SWFPrebuiltClip */
4242 /* {{{ proto class swfprebuiltclip_init(filename / SWFInput )
4243 Returns a SWFPrebuiltClip object */
4244 PHP_METHOD(swfprebuiltclip, __construct)
4245 {
4246 zval *zfile = NULL;
4247 SWFPrebuiltClip clip;
4248 SWFInput input = NULL;
4249 #if PHP_VERSION_ID >= 70000
4250 zend_resource *ret;
4251 #else
4252 int ret;
4253 #endif
4254
4255 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zfile) == FAILURE) {
4256 return;
4257 }
4258
4259 switch(Z_TYPE_P(zfile))
4260 {
4261 case IS_RESOURCE:
4262 input = getInput_fromFileResource(zfile TSRMLS_CC);
4263 break;
4264 case IS_OBJECT:
4265 input = getInput(zfile TSRMLS_CC);
4266 break;
4267 case IS_STRING:
4268 input = newSWFInput_filename(Z_STRVAL_P(zfile));
4269 if(input == NULL)
4270 php_error(E_ERROR, "opening prebuilt clip file failed");
4271 #if PHP_VERSION_ID >= 70000
4272 zend_register_resource(input, le_swfinputp);
4273 #else
4274 zend_list_addref(zend_list_insert(input, le_swfinputp));
4275 #endif
4276 break;
4277
4278 default:
4279 php_error(E_ERROR, "swfprebuiltclip_init: need either a filename, "
4280 "a file ressource or SWFInput buffer.");
4281 }
4282
4283 clip = newSWFPrebuiltClip_fromInput(input);
4284
4285 if(clip) {
4286 #if PHP_VERSION_ID >= 70000
4287 ret = zend_register_resource(clip, le_swfprebuiltclipp);
4288 add_property_resource(getThis(), "prebuiltclip", ret);
4289 #else
4290 object_init_ex(getThis(), prebuiltclip_class_entry_ptr);
4291 ret = zend_list_insert(clip, le_swfprebuiltclipp);
4292 add_property_resource(getThis(), "prebuiltclip", ret);
4293 zend_list_addref(ret);
4294 #endif
4295 }
4296 }
4297 /* }}} */
4298
4299 /* {{{ internal function destroy_SWFPrebuiltClip */
4300 #if PHP_VERSION_ID >= 70000
4301 static void destroy_SWFPrebuiltClip_resource(zend_resource *resource)
4302 #else
4303 static void destroy_SWFPrebuiltClip_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
4304 #endif
4305 {
4306 destroySWFPrebuiltClip((SWFPrebuiltClip)resource->ptr);
4307 }
4308 /* }}} */
4309
4310 /* {{{ internal function getPrebuiltClip
4311 Returns the SWFPrebuiltClip object contained in zval *id */
4312 static SWFPrebuiltClip getPrebuiltClip(zval *id TSRMLS_DC)
4313 {
4314 void *clip = SWFgetProperty(id, "prebuiltclip", 12, le_swfprebuiltclipp TSRMLS_CC);
4315 if(!clip)
4316 php_error(E_ERROR, "called object is not an SWFPrebuiltClip!");
4317 return (SWFPrebuiltClip)clip;
4318 }
4319 /* }}} */
4320
4321 static zend_function_entry swfprebuiltclip_functions[] = {
4322 PHP_ME(swfprebuiltclip, __construct, NULL, 0)
4323 { NULL, NULL, NULL }
4324 };
4325
4326 /* }}} */
4327 #endif
4328
4329 /* {{{ SWFMovie
4330 */
4331 /* {{{ proto void swfmovie::__construct(int version)
4332 Creates swfmovie object according to the passed version */
4333 PHP_METHOD(swfmovie, __construct)
4334 {
4335 zend_long version;
4336 SWFMovie movie;
4337 #if PHP_VERSION_ID >= 70000
4338 zend_resource *ret;
4339 #else
4340 int ret;
4341 #endif
4342
4343 if (ZEND_NUM_ARGS() == 1) {
4344 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &version) == FAILURE) {
4345 return;
4346 }
4347 movie = newSWFMovieWithVersion(version);
4348 } else {
4349 movie = newSWFMovie(); /* default version 4 */
4350 }
4351
4352 #if PHP_VERSION_ID >= 70000
4353 ret = zend_register_resource(movie, le_swfmoviep);
4354 add_property_resource(getThis(), "movie", ret);
4355 #else
4356 object_init_ex(getThis(), movie_class_entry_ptr);
4357 ret = zend_list_insert(movie, le_swfmoviep);
4358
4359 add_property_resource(getThis(), "movie", ret);
4360 zend_list_addref(ret);
4361 #endif
4362 }
4363
4364 #if PHP_VERSION_ID >= 70000
4365 static void destroy_SWFMovie_resource(zend_resource *resource)
4366 #else
4367 static void destroy_SWFMovie_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
4368 #endif
4369 {
4370 destroySWFMovie((SWFMovie)resource->ptr);
4371 }
4372 /* }}} */
4373
4374 /* {{{ getMovie
4375 */
4376 static SWFMovie getMovie(zval *id TSRMLS_DC)
4377 {
4378 void *movie = SWFgetProperty(id, "movie", 5, le_swfmoviep TSRMLS_CC);
4379
4380 if (!movie) {
4381 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMovie");
4382 }
4383 return (SWFMovie)movie;
4384 }
4385 /* }}} */
4386
4387 /* {{{ proto void swfmovie::nextframe()
4388 */
4389 PHP_METHOD(swfmovie, nextFrame)
4390 {
4391 SWFMovie_nextFrame(getMovie(getThis() TSRMLS_CC));
4392 }
4393 /* }}} */
4394
4395 /* {{{ proto void swfmovie::labelframe(string label)
4396 Labels frame */
4397 PHP_METHOD(swfmovie, labelFrame)
4398 {
4399 char *label;
4400 zend_strlen label_len;
4401
4402 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &label, &label_len) == FAILURE) {
4403 return;
4404 }
4405
4406 SWFMovie_labelFrame(getMovie(getThis() TSRMLS_CC), label);
4407 }
4408 /* }}} */
4409
4410 /* {{{ proto void swfmovie::namedanchor()
4411 */
4412 PHP_METHOD(swfmovie, namedAnchor)
4413 {
4414 char *label;
4415 zend_strlen label_len;
4416
4417 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &label, &label_len) == FAILURE) {
4418 return;
4419 }
4420
4421 SWFMovie_namedAnchor(getMovie(getThis() TSRMLS_CC), label);
4422 }
4423 /* }}} */
4424
4425 /* {{{ proto void swfmovie::protect([ string pasword])
4426 */
4427 PHP_METHOD(swfmovie, protect)
4428 {
4429 char *passwd = NULL;
4430 zend_strlen passwd_len;
4431 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4432
4433 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &passwd, &passwd_len) == FAILURE) {
4434 return;
4435 }
4436 SWFMovie_protect(movie, passwd);
4437 }
4438 /* }}} */
4439
4440 /* {{{ proto object swfmovie::add(object SWFBlock)
4441 */
4442 PHP_METHOD(swfmovie, add)
4443 {
4444 zval *zchar;
4445 #if PHP_VERSION_ID >= 70000
4446 zend_resource *ret;
4447 #else
4448 int ret;
4449 #endif
4450 SWFBlock block;
4451 SWFDisplayItem item;
4452 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4453 SWFMovieBlockType ublock;
4454
4455 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) {
4456 return;
4457 }
4458
4459 /* XXX - SWFMovie_add deals w/ all block types. Probably will need to add that.. */
4460 if (Z_OBJCE_P(zchar) == action_class_entry_ptr) {
4461 block = (SWFBlock) getAction(zchar TSRMLS_CC);
4462 }
4463 else if (Z_OBJCE_P(zchar) == initaction_class_entry_ptr) {
4464 block = (SWFBlock) getInitAction(zchar TSRMLS_CC);
4465 }
4466 else if(Z_OBJCE_P(zchar) == character_class_entry_ptr) {
4467 block = (SWFBlock) getCharacterClass(zchar TSRMLS_CC);
4468 }
4469 else {
4470 block = (SWFBlock) getCharacter(zchar TSRMLS_CC);
4471 }
4472
4473 ublock.block = block;
4474 item = SWFMovie_add_internal(movie, ublock);
4475 if (item != NULL) {
4476 /* try and create a displayitem object */
4477 object_init_ex(return_value, displayitem_class_entry_ptr);
4478 #if PHP_VERSION_ID >= 70000
4479 ret = zend_register_resource(item, le_swfdisplayitemp);
4480 add_property_resource(return_value, "displayitem", ret);
4481 ret->gc.refcount++;
4482 #else
4483 ret = zend_list_insert(item, le_swfdisplayitemp);
4484 add_property_resource(return_value, "displayitem", ret);
4485 zend_list_addref(ret);
4486 #endif
4487 }
4488 }
4489 /* }}} */
4490
4491 /* {{{ proto void swfmovie::remove(object SWFBlock)
4492 */
4493 PHP_METHOD(swfmovie, remove)
4494 {
4495 zval *zchar;
4496 SWFDisplayItem item;
4497 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4498
4499 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) {
4500 return;
4501 }
4502 item = getDisplayItem(zchar TSRMLS_CC);
4503 SWFMovie_remove(movie, item);
4504 }
4505 /* }}} */
4506
4507 /* {{{ proto int swfmovie::output([int compression])
4508 */
4509 static void phpByteOutputMethod(byte b, void *data)
4510 {
4511 TSRMLS_FETCH();
4512
4513 php_write(&b, 1 TSRMLS_CC);
4514 }
4515
4516 PHP_METHOD(swfmovie, output)
4517 {
4518 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4519 #if !defined(HAVE_NEW_MING)
4520 zend_long limit = -1;
4521 int oldval = INT_MIN;
4522 long out;
4523
4524 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &limit) == FAILURE) {
4525 return;
4526 }
4527 oldval = Ming_setSWFCompression(limit);
4528 out = SWFMovie_output(movie, &phpByteOutputMethod, NULL);
4529 Ming_setSWFCompression(oldval);
4530
4531 RETURN_LONG(out);
4532 #elif defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL)
4533 zend_long limit = -1;
4534 int argc = ZEND_NUM_ARGS();
4535
4536 if(argc) {
4537 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &limit) == FAILURE) {
4538 return;
4539 }
4540
4541 if ((limit < 0) || (limit > 9)) {
4542 php_error(E_WARNING,"compression level must be within 0..9");
4543 RETURN_FALSE;
4544 }
4545 }
4546 RETURN_LONG(SWFMovie_output(movie, &phpByteOutputMethod, NULL, limit));
4547 #else
4548 RETURN_LONG(SWFMovie_output(movie, &phpByteOutputMethod, NULL));
4549 #endif
4550
4551 }
4552 /* }}} */
4553
4554 /* {{{ proto int swfmovie::saveToFile(stream x [, int compression])
4555 */
4556 static void phpStreamOutputMethod(byte b, void * data)
4557 {
4558 TSRMLS_FETCH();
4559
4560 php_stream_write((php_stream*)data, &b, 1);
4561 }
4562
4563 /* I'm not sure about the logic here as Ming_setSWFCompression() should be
4564 * used with current Ming. I'll have to add some tests to the test suite to
4565 * verify this functionallity before I can say for sure
4566 */
4567 PHP_METHOD(swfmovie, saveToFile)
4568 {
4569 zval *x;
4570 zend_long limit = -1;
4571 #if !defined(HAVE_NEW_MING)
4572 int oldval = INT_MIN;
4573 #endif
4574 long out;
4575
4576 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4577 php_stream *what;
4578
4579 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &x, &limit) == FAILURE) {
4580 return;
4581 }
4582
4583 if ((limit < 0) || (limit > 9)) {
4584 php_error(E_WARNING,"compression level must be within 0..9");
4585 RETURN_FALSE;
4586 }
4587 #if !defined(HAVE_NEW_MING)
4588 oldval = Ming_setSWFCompression(limit);
4589 #endif
4590
4591 #if PHP_VERSION_ID >= 70000
4592 if ((what = (php_stream*)zend_fetch_resource2_ex(x,
4593 "File-Handle", php_file_le_stream(), php_file_le_pstream())) == NULL) {
4594 RETURN_FALSE;
4595 }
4596 #else
4597 ZEND_FETCH_RESOURCE(what, php_stream *, &x, -1,"File-Handle",php_file_le_stream());
4598 #endif
4599 #if !defined(HAVE_NEW_MING)
4600 out = SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, what);
4601 Ming_setSWFCompression(oldval);
4602 #elif defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL)
4603 out = SWFMovie_output(movie, &phpStreamOutputMethod, what, limit);
4604 #else
4605 out = SWFMovie_output(movie, &phpStreamOutputMethod, what);
4606 #endif
4607 RETURN_LONG(out);
4608 }
4609 /* }}} */
4610
4611 /* {{{ proto int swfmovie::save(mixed where [, int compression])
4612 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 */
4613 PHP_METHOD(swfmovie, save)
4614 {
4615 zval *x;
4616 long limit = -1;
4617 #if !defined(HAVE_NEW_MING)
4618 int oldval = INT_MIN;
4619 #endif
4620 zend_long retval;
4621 php_stream *stream;
4622
4623 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &x, &limit) == FAILURE) {
4624 return;
4625 }
4626
4627 #if !defined(HAVE_NEW_MING)
4628 oldval = Ming_setSWFCompression(limit);
4629 #endif
4630
4631 if (Z_TYPE_P(x) == IS_RESOURCE) {
4632 #if PHP_VERSION_ID >= 70000
4633 if ((stream = (php_stream*)zend_fetch_resource2_ex(x,
4634 "File-Handle", php_file_le_stream(), php_file_le_pstream())) == NULL) {
4635 RETURN_FALSE;
4636 }
4637 #else
4638 ZEND_FETCH_RESOURCE(stream, php_stream *, &x, -1,"File-Handle",php_file_le_stream());
4639 #endif
4640 #if defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL)
4641 RETURN_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, stream, limit));
4642 #else
4643 RETVAL_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, stream));
4644 #if !defined(HAVE_NEW_MING)
4645 Ming_setSWFCompression(oldval);
4646 #endif
4647 return;
4648 #endif
4649 }
4650
4651 convert_to_string(x);
4652 #if PHP_VERSION_ID >= 70000
4653 stream = php_stream_open_wrapper(Z_STRVAL_P(x), "wb", REPORT_ERRORS, NULL);
4654 #else
4655 stream = php_stream_open_wrapper(Z_STRVAL_P(x), "wb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
4656 #endif
4657
4658 if (stream == NULL) {
4659 RETURN_FALSE;
4660 }
4661
4662 #if defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL)
4663 retval = SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, (void *)stream, limit);
4664 #else
4665 retval = SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, (void *)stream);
4666 #endif
4667 php_stream_close(stream);
4668 #if!defined(HAVE_NEW_MING)
4669 Ming_setSWFCompression(oldval);
4670 #endif
4671
4672 RETURN_LONG(retval);
4673 }
4674 /* }}} */
4675
4676 /* {{{ proto void swfmovie::setBackground(int r, int g, int b)
4677 Sets background color (r,g,b) */
4678 PHP_METHOD(swfmovie, setBackground)
4679 {
4680 zend_long r, g, b;
4681 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4682
4683 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &r, &g, &b) == FAILURE) {
4684 return;
4685 }
4686
4687 SWFMovie_setBackground(movie, r, g, b);
4688 }
4689 /* }}} */
4690
4691 /* {{{ proto void swfmovie::setRate(float rate)
4692 Sets movie rate */
4693 PHP_METHOD(swfmovie, setRate)
4694 {
4695 double rate;
4696 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4697
4698 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &rate) == FAILURE) {
4699 return;
4700 }
4701
4702 SWFMovie_setRate(movie, rate);
4703 }
4704 /* }}} */
4705
4706 /* {{{ proto void swfmovie::setDimension(float x, float y)
4707 Sets movie dimension */
4708 PHP_METHOD(swfmovie, setDimension)
4709 {
4710 double x, y;
4711 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4712
4713 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
4714 return;
4715 }
4716
4717 SWFMovie_setDimension(movie, x, y);
4718 }
4719 /* }}} */
4720
4721 /* {{{ proto void swfmovie::setFrames(int frames)
4722 Sets number of frames */
4723 PHP_METHOD(swfmovie, setFrames)
4724 {
4725 zend_long frames;
4726 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4727
4728 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &frames) == FAILURE) {
4729 return;
4730 }
4731
4732 SWFMovie_setNumberOfFrames(movie, frames);
4733 }
4734 /* }}} */
4735
4736 #ifdef HAVE_NEW_MING
4737 /* {{{ proto void swfmovie::addMetadata(string xml)
4738 * */
4739 PHP_METHOD(swfmovie, addMetadata)
4740 {
4741 char *xml;
4742 zend_strlen xml_len;
4743
4744 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4745
4746 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &xml, &xml_len) == FAILURE) {
4747 return;
4748 }
4749
4750 SWFMovie_addMetadata(movie, xml);
4751 }
4752 /* }}} */
4753
4754 /* {{{ proto void swfmovie::setScriptLimits(int maxRecursion, int timeout)
4755 */
4756 PHP_METHOD(swfmovie, setScriptLimits)
4757 {
4758 zend_long maxRecursion, timeout;
4759 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4760
4761 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &maxRecursion, &timeout) == FAILURE) {
4762 return;
4763 }
4764
4765 SWFMovie_setScriptLimits(movie, maxRecursion, timeout);
4766 }
4767 /* }}} */
4768
4769 /* {{{ proto void swfmovie::setTabIndex(int depth, int index)
4770 * */
4771 PHP_METHOD(swfmovie, setTabIndex)
4772 {
4773 zend_long depth, index;
4774 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4775
4776 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &depth, &index) == FAILURE) {
4777 return;
4778 }
4779
4780 SWFMovie_setTabIndex(movie, depth, index);
4781 }
4782 /* }}} */
4783
4784 /* {{{ proto void swfmovie::assignSymbol(SWFCharacter character, string name)
4785 * */
4786 PHP_METHOD(swfmovie, assignSymbol)
4787 {
4788 zval *zchar;
4789 char *name;
4790 zend_strlen name_len;
4791 SWFCharacter character;
4792 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4793
4794 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os", &zchar, &name, &name_len) == FAILURE) {
4795 return;
4796 }
4797
4798 character = getCharacter(zchar TSRMLS_CC);
4799 SWFMovie_assignSymbol(movie, character, name);
4800 }
4801 /* }}} */
4802
4803 /* {{{ proto void swfmovie::defineScene(int offset, string name)
4804 * */
4805 PHP_METHOD(swfmovie, defineScene)
4806 {
4807 zend_long offset;
4808 char *name;
4809 zend_strlen name_len;
4810 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4811
4812 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &offset, &name, &name_len) == FAILURE) {
4813 return;
4814 }
4815
4816 SWFMovie_defineScene(movie, offset, name);
4817 }
4818 /* }}} */
4819
4820 /* {{{ proto void swfmovie::setNetworkAccess(int flag)
4821 * */
4822 PHP_METHOD(swfmovie, setNetworkAccess)
4823 {
4824 zend_long flag;
4825 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4826
4827 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) {
4828 return;
4829 }
4830
4831 SWFMovie_setNetworkAccess(movie, flag);
4832 }
4833 /* }}} */
4834
4835 /* {{{ proto long swfmovie::streamMP3(mixed filename / SWFInput [, double skip])
4836 Sets sound stream of the SWF movie. The parameter can be stream or string. */
4837 PHP_METHOD(swfmovie, streamMP3)
4838 {
4839 zval *zfile;
4840 double skip = 0;
4841 SWFSoundStream sound;
4842 SWFInput input = NULL;
4843 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4844
4845 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|d", &zfile, &skip) == FAILURE) {
4846 return;
4847 }
4848
4849 switch(Z_TYPE_P(zfile))
4850 {
4851 case IS_RESOURCE:
4852 input = getInput_fromFileResource(zfile TSRMLS_CC);
4853 break;
4854 case IS_OBJECT:
4855 input = getInput(zfile TSRMLS_CC);
4856 break;
4857 case IS_STRING:
4858 input = newSWFInput_filename(Z_STRVAL_P(zfile));
4859 if (input == NULL) {
4860 php_error(E_ERROR, "opening mp3 file failed");
4861 }
4862
4863 #if PHP_VERSION_ID >= 70000
4864 zend_register_resource(input, le_swfinputp);
4865 #else
4866 zend_list_addref(zend_list_insert(input, le_swfinputp));
4867 #endif
4868 break;
4869
4870 default:
4871 php_error(E_ERROR, "swfmovie::streamMP3: need either a filename, "
4872 "a file ressource or SWFInput buffer.");
4873 }
4874
4875 sound = newSWFSoundStream_fromInput(input);
4876 SWFMovie_setSoundStreamAt(movie, sound, skip);
4877 RETURN_LONG(SWFSoundStream_getDuration(sound) / SWFMovie_getRate(movie));
4878 }
4879 /* }}} */
4880
4881 /* {{{ proto long swfmovie::setSoundStream
4882 Sets sound stream of the SWF movie. The parameter must be a SoundStream object */
4883 PHP_METHOD(swfmovie, setSoundStream)
4884 {
4885 zval *zstream;
4886 double skip = 0;
4887 SWFSoundStream sound;
4888 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4889
4890 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|d", &zstream, &skip) == FAILURE) {
4891 return;
4892 }
4893
4894 sound = getSoundStream(zstream TSRMLS_CC);
4895 SWFMovie_setSoundStreamAt(movie, sound, skip);
4896 RETURN_LONG(SWFSoundStream_getDuration(sound) / SWFMovie_getRate(movie));
4897 }
4898 /* }}} */
4899
4900 /* {{{ swfmovie_addexport */
4901
4902 PHP_METHOD(swfmovie, addExport)
4903 {
4904 zval *zchar;
4905 char *name;
4906 zend_strlen name_len;
4907 SWFBlock block;
4908 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4909
4910 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os", &zchar, &name, &name_len) == FAILURE) {
4911 return;
4912 }
4913
4914 block = (SWFBlock)getCharacter(zchar TSRMLS_CC);
4915
4916 SWFMovie_addExport(movie, block, name);
4917 }
4918
4919 /* }}} */
4920
4921 /* {{{ swfmovie_writeexports */
4922 PHP_METHOD(swfmovie, writeExports)
4923 {
4924 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4925
4926 SWFMovie_writeExports(movie);
4927 }
4928
4929 /* }}} */
4930 /* {{{ SWFSoundInstance swfmovie_startsound */
4931
4932 PHP_METHOD(swfmovie, startSound)
4933 {
4934 zval *zsound;
4935 #if PHP_VERSION_ID >= 70000
4936 zend_resource *ret;
4937 #else
4938 int ret;
4939 #endif
4940 SWFSound sound;
4941 SWFSoundInstance item;
4942 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4943
4944 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) {
4945 return;
4946 }
4947
4948 sound = (SWFSound)getSound(zsound TSRMLS_CC);
4949
4950 item = SWFMovie_startSound(movie, sound);
4951
4952 if(item != NULL)
4953 {
4954 /* try and create a soundinstance object */
4955 object_init_ex(return_value, soundinstance_class_entry_ptr);
4956 #if PHP_VERSION_ID >= 70000
4957 ret = zend_register_resource(item, le_swfsoundinstancep);
4958 add_property_resource(return_value, "soundinstance", ret);
4959 ret->gc.refcount++;
4960 #else
4961 ret = zend_list_insert(item, le_swfsoundinstancep);
4962 add_property_resource(return_value, "soundinstance", ret);
4963 zend_list_addref(ret);
4964 #endif
4965 }
4966 }
4967 /* }}} */
4968
4969 /* {{{ void swfmovie::stopsound(sound) */
4970 PHP_METHOD(swfmovie, stopSound)
4971 {
4972 zval *zsound;
4973 SWFSound sound;
4974 SWFMovie movie = getMovie(getThis() TSRMLS_CC);
4975
4976 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) {
4977 return;
4978 }
4979
4980 sound = (SWFSound)getSound(zsound TSRMLS_CC);
4981
4982 SWFMovie_stopSound(movie, sound);
4983 }
4984 /* }}} */
4985
4986 /* {{{ void swfmovie::importChar(filename, importname) */
4987 PHP_METHOD(swfmovie, importChar)
4988 {
4989 SWFMovie movie;
4990 SWFCharacter character;
4991 char *libswf, *name;
4992 zend_strlen libswf_len, name_len;
4993 #if PHP_VERSION_ID >= 70000
4994 zend_resource *ret;
4995 #else
4996 int ret;
4997 #endif
4998
4999 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &libswf, &libswf_len, &name, &name_len) == FAILURE) {
5000 return;
5001 }
5002
5003 movie = getMovie(getThis() TSRMLS_CC);
5004 character = SWFMovie_importCharacter(movie, libswf, name);
5005 if(character != NULL)
5006 {
5007 object_init_ex(return_value, character_class_entry_ptr);
5008 #if PHP_VERSION_ID >= 70000
5009 ret = zend_register_resource(character, le_swfcharacterp);
5010 add_property_resource(return_value, "character", ret);
5011 ret->gc.refcount++;
5012 #else
5013 ret = zend_list_insert(character, le_swfcharacterp);
5014 add_property_resource(return_value, "character", ret);
5015 zend_list_addref(ret);
5016 #endif
5017 }
5018 }
5019 /* }}} */
5020
5021 /* {{{ void swfmovie_importFont */
5022 PHP_METHOD(swfmovie, importFont)
5023 {
5024 SWFMovie movie;
5025 SWFFontCharacter res;
5026 char *libswf, *name;
5027 zend_strlen libswf_len, name_len;
5028 #if PHP_VERSION_ID >= 70000
5029 zend_resource *ret;
5030 #else
5031 int ret;
5032 #endif
5033
5034 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &libswf, &libswf_len, &name, &name_len) == FAILURE) {
5035 return;
5036 }
5037
5038 movie = getMovie(getThis() TSRMLS_CC);
5039 PHP_MING_FILE_CHK(libswf);
5040 res = SWFMovie_importFont(movie, libswf, name);
5041
5042 if(res != NULL)
5043 {
5044 /* try and create a fontchar object */
5045 object_init_ex(return_value, fontchar_class_entry_ptr);
5046 #if PHP_VERSION_ID >= 70000
5047 ret = zend_register_resource(res, le_swffontcharp);
5048 add_property_resource(return_value, "fontcharacter", ret);
5049 ret->gc.refcount++;
5050 #else
5051 ret = zend_list_insert(res, le_swffontcharp);
5052 add_property_resource(return_value, "fontcharacter", ret);
5053 zend_list_addref(ret);
5054 #endif
5055 }
5056 }
5057 /* }}} */
5058
5059 /* {{{ void swfmovie_addFont */
5060 PHP_METHOD(swfmovie, addFont)
5061 {
5062 SWFMovie movie;
5063 SWFFontCharacter res;
5064 #if PHP_VERSION_ID >= 70000
5065 zend_resource *ret;
5066 #else
5067 int ret;
5068 #endif
5069 SWFFont font;
5070 zval *zfont;
5071
5072 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfont) == FAILURE) {
5073 return;
5074 }
5075
5076 movie = getMovie(getThis() TSRMLS_CC);
5077 font = getFont(zfont TSRMLS_CC);
5078 res = SWFMovie_addFont(movie, font);
5079 if(res != NULL)
5080 {
5081 /* try and create a fontchar object */
5082 object_init_ex(return_value, fontchar_class_entry_ptr);
5083 #if PHP_VERSION_ID >= 70000
5084 ret = zend_register_resource(res, le_swffontcharp);
5085 add_property_resource(return_value, "fontcharacter", ret);
5086 ret->gc.refcount++;
5087 #else
5088 ret = zend_list_insert(res, le_swffontcharp);
5089 add_property_resource(return_value, "fontcharacter", ret);
5090 zend_list_addref(ret);
5091 #endif
5092 }
5093 }
5094 /* }}} */
5095
5096 /* {{{ void swfmovie_replace */
5097 PHP_METHOD(swfmovie, replace)
5098 {
5099 SWFMovie movie;
5100 zval *zitem, *zblock;
5101 SWFDisplayItem item;
5102 SWFBlock block;
5103 SWFMovieBlockType ublock;
5104
5105 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oo", &zitem, &zblock) == FAILURE) {
5106 return;
5107 }
5108
5109 item = getDisplayItem(zitem TSRMLS_CC);
5110
5111 block = (SWFBlock) getCharacter(zblock TSRMLS_CC);
5112 movie = getMovie(getThis() TSRMLS_CC);
5113 ublock.block = block;
5114
5115 SWFMovie_replace_internal(movie, item, ublock);
5116 }
5117 /* }}} */
5118
5119 /* {{{ float swfmovie::getRate() */
5120 PHP_METHOD(swfmovie, getRate)
5121 {
5122 RETURN_DOUBLE(SWFMovie_getRate(getMovie(getThis() TSRMLS_CC)));
5123 }
5124 /* }}} */
5125 #endif
5126
5127 static zend_function_entry swfmovie_functions[] = {
5128 PHP_ME(swfmovie, __construct, NULL, 0)
5129 PHP_ME(swfmovie, nextFrame, NULL, 0)
5130 PHP_ME(swfmovie, labelFrame, NULL, 0)
5131 PHP_ME(swfmovie, add, NULL, 0)
5132 PHP_ME(swfmovie, remove, NULL, 0)
5133 PHP_ME(swfmovie, output, NULL, 0)
5134 PHP_ME(swfmovie, save, NULL, 0)
5135 PHP_ME(swfmovie, saveToFile, NULL, 0)
5136 PHP_ME(swfmovie, setBackground, NULL, 0)
5137 PHP_ME(swfmovie, setRate, NULL, 0)
5138 PHP_ME(swfmovie, setDimension, NULL, 0)
5139 PHP_ME(swfmovie, setFrames, NULL, 0)
5140 #ifdef HAVE_NEW_MING
5141 PHP_ME(swfmovie, streamMP3, NULL, 0)
5142 PHP_ME(swfmovie, setSoundStream, NULL, 0)
5143 PHP_ME(swfmovie, addExport, NULL, 0)
5144 PHP_ME(swfmovie, writeExports, NULL, 0)
5145 PHP_ME(swfmovie, startSound, NULL, 0)
5146 PHP_ME(swfmovie, stopSound, NULL, 0)
5147 PHP_ME(swfmovie, importChar, NULL, 0)
5148 PHP_ME(swfmovie, importFont, NULL, 0)
5149 PHP_ME(swfmovie, addFont, NULL, 0)
5150 PHP_ME(swfmovie, protect, NULL, 0)
5151 PHP_ME(swfmovie, addMetadata, NULL, 0)
5152 PHP_ME(swfmovie, setNetworkAccess, NULL, 0)
5153 PHP_ME(swfmovie, setScriptLimits, NULL, 0)
5154 PHP_ME(swfmovie, setTabIndex, NULL, 0)
5155 PHP_ME(swfmovie, assignSymbol, NULL, 0)
5156 PHP_ME(swfmovie, defineScene, NULL, 0)
5157 PHP_ME(swfmovie, namedAnchor, NULL, 0)
5158 PHP_ME(swfmovie, replace, NULL, 0)
5159 PHP_ME(swfmovie, getRate, NULL, 0)
5160 #endif
5161 { NULL, NULL, NULL }
5162 };
5163
5164 /* }}} */
5165
5166 /* {{{ SWFShape
5167 */
5168 /* {{{ proto void swfshape::__construct()
5169 Creates a new SWFShape object */
5170 PHP_METHOD(swfshape, __construct)
5171 {
5172 SWFShape shape = newSWFShape();
5173 #if PHP_VERSION_ID >= 70000
5174 zend_resource *ret = zend_register_resource(shape, le_swfshapep);
5175 add_property_resource(getThis(), "shape", ret);
5176 #else
5177 int ret = zend_list_insert(shape, le_swfshapep);
5178 object_init_ex(getThis(), shape_class_entry_ptr);
5179 add_property_resource(getThis(), "shape", ret);
5180 zend_list_addref(ret);
5181 #endif
5182 }
5183
5184 #if PHP_VERSION_ID >= 70000
5185 static void destroy_SWFShape_resource(zend_resource *resource)
5186 #else
5187 static void destroy_SWFShape_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
5188 #endif
5189 {
5190 destroySWFShape((SWFShape)resource->ptr);
5191 }
5192 /* }}} */
5193
5194 /* {{{ internal function getShape
5195 Returns the SWFShape object contained in zval *id */
5196 static SWFShape getShape(zval *id TSRMLS_DC)
5197 {
5198 void *shape = SWFgetProperty(id, "shape", 5, le_swfshapep TSRMLS_CC);
5199
5200 if (!shape) {
5201 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFShape");
5202 }
5203
5204 return (SWFShape)shape;
5205 }
5206 /* }}} */
5207
5208 /* {{{ proto void swfshape::setline(int width, int r, int g, int b [, int a])
5209 Sets the current line style for this SWFShape */
5210 PHP_METHOD(swfshape, setLine)
5211 {
5212 zend_long w, r, g, b, a = 0xff;
5213
5214 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll|l", &w, &r, &g, &b, &a) == FAILURE) {
5215 return;
5216 }
5217
5218 SWFShape_setLine(getShape(getThis() TSRMLS_CC), (unsigned short)w, (byte)r, (byte)g, (byte)b, (byte)a);
5219 }
5220 /* }}} */
5221
5222 /* {{{ proto object swfshape::addSolidFill(int r, int g, int b, [int alpha])
5223 Returns a solid fill object, for use with swfshape_setleftfill and swfshape_setrightfill. */
5224 PHP_METHOD(swfshape, addSolidFill)
5225 {
5226 SWFFill fill=NULL;
5227 #if PHP_VERSION_ID >= 70000
5228 zend_resource *ret;
5229 #else
5230 int ret;
5231 #endif
5232
5233 if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) {
5234 /* it's a solid fill */
5235 zend_long r, g, b, a = 0xff;
5236
5237 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) {
5238 return;
5239 }
5240
5241 fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a);
5242 } else {
5243 WRONG_PARAM_COUNT;
5244 }
5245
5246 if (!fill) {
5247 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding fill to shape");
5248 }
5249
5250 /* return an SWFFill object */
5251 object_init_ex(return_value, fill_class_entry_ptr);
5252 #if PHP_VERSION_ID >= 70000
5253 ret = zend_register_resource(fill, le_swffillp);
5254 add_property_resource(return_value, "fill", ret);
5255 ret->gc.refcount++;
5256 #else
5257 ret = zend_list_insert(fill, le_swffillp);
5258 add_property_resource(return_value, "fill", ret);
5259 zend_list_addref(ret);
5260 #endif
5261 }
5262 /* }}} */
5263
5264 /* {{{ proto object swfshape::addbitmapfill(bitmap, [flags])
5265 Returns a bitmap fill object, for use with swfshape_setleftfill and swfshape_setrightfill. */
5266 PHP_METHOD(swfshape, addBitmapFill)
5267 {
5268 SWFFill fill=NULL;
5269 #if PHP_VERSION_ID >= 70000
5270 zend_resource *ret;
5271 #else
5272 int ret;
5273 #endif
5274
5275 if (ZEND_NUM_ARGS() == 1 || ZEND_NUM_ARGS() == 2) {
5276 /* it's a gradient or bitmap */
5277 zval *arg1;
5278 zend_long flags = 0;
5279
5280 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o!|l", &arg1, &flags) == FAILURE) {
5281 return;
5282 }
5283
5284 if ( arg1 && Z_OBJCE_P(arg1) != bitmap_class_entry_ptr) {
5285
5286 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Argument is not a bitmap");
5287 }
5288
5289 if (flags == 0) {
5290 flags = SWFFILL_TILED_BITMAP;
5291 }
5292 fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC),
5293 arg1 ? getBitmap(arg1 TSRMLS_CC) : 0, flags);
5294
5295 } else {
5296 WRONG_PARAM_COUNT;
5297 }
5298
5299 if (!fill) {
5300 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding bitmap fill to shape");
5301 }
5302
5303 /* return an SWFFill object */
5304 object_init_ex(return_value, fill_class_entry_ptr);
5305 #if PHP_VERSION_ID >= 70000
5306 ret = zend_register_resource(fill, le_swffillp);
5307 add_property_resource(return_value, "fill", ret);
5308 ret->gc.refcount++;
5309 #else
5310 ret = zend_list_insert(fill, le_swffillp);
5311 add_property_resource(return_value, "fill", ret);
5312 zend_list_addref(ret);
5313 #endif
5314 }
5315 /* }}} */
5316
5317 /* {{{ proto object swfshape::addGradientFill(gradient, [flags])
5318 Returns a gradient fill object, for use with swfshape_setleftfill and swfshape_setrightfill. */
5319 PHP_METHOD(swfshape, addGradientFill)
5320 {
5321 SWFFill fill=NULL;
5322 #if PHP_VERSION_ID >= 70000
5323 zend_resource *ret;
5324 #else
5325 int ret;
5326 #endif
5327
5328 if (ZEND_NUM_ARGS() == 1 || ZEND_NUM_ARGS() == 2) {
5329 /* it's a gradient or bitmap */
5330 zval *arg1;
5331 zend_long flags = 0;
5332
5333 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &arg1, &flags) == FAILURE) {
5334 return;
5335 }
5336
5337 if (Z_OBJCE_P(arg1) == gradient_class_entry_ptr) {
5338 if (flags == 0) {
5339 flags = SWFFILL_LINEAR_GRADIENT;
5340 }
5341 fill = SWFShape_addGradientFill(getShape(getThis() TSRMLS_CC), getGradient(arg1 TSRMLS_CC), flags);
5342 } else if (Z_OBJCE_P(arg1) == bitmap_class_entry_ptr) {
5343 if (flags == 0) {
5344 flags = SWFFILL_TILED_BITMAP;
5345 }
5346 fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC), getBitmap(arg1 TSRMLS_CC), flags);
5347 } else {
5348 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Argument is not a bitmap nor a gradient");
5349 }
5350
5351 } else {
5352 WRONG_PARAM_COUNT;
5353 }
5354
5355 if (!fill) {
5356 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding fill to shape");
5357 }
5358
5359 /* return an SWFFill object */
5360 object_init_ex(return_value, fill_class_entry_ptr);
5361 #if PHP_VERSION_ID >= 70000
5362 ret = zend_register_resource(fill, le_swffillp);
5363 add_property_resource(return_value, "fill", ret);
5364 ret->gc.refcount++;
5365 #else
5366 ret = zend_list_insert(fill, le_swffillp);
5367 add_property_resource(return_value, "fill", ret);
5368 zend_list_addref(ret);
5369 #endif
5370 }
5371 /* }}} */
5372
5373 /* {{{ proto object swfshape::addfill(mixed arg1, int arg2, [int b [, int a]])
5374 Returns a fill object, for use with swfshape_setleftfill and swfshape_setrightfill. If 1 or 2 parameter(s) is (are) passed first should be object (from gradient class) and the second int (flags). Gradient fill is performed. If 3 or 4 parameters are passed : r, g, b [, a]. Solid fill is performed. */
5375 PHP_METHOD(swfshape, addFill)
5376 {
5377 SWFFill fill=NULL;
5378 #if PHP_VERSION_ID >= 70000
5379 zend_resource *ret;
5380 #else
5381 int ret;
5382 #endif
5383
5384 if (ZEND_NUM_ARGS() == 1 || ZEND_NUM_ARGS() == 2) {
5385 /* it's a gradient or bitmap */
5386 zval *arg1;
5387 zend_long flags = 0;
5388
5389 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &arg1, &flags) == FAILURE) {
5390 return;
5391 }
5392
5393 if (Z_OBJCE_P(arg1) == gradient_class_entry_ptr) {
5394 if (flags == 0) {
5395 flags = SWFFILL_LINEAR_GRADIENT;
5396 }
5397 fill = SWFShape_addGradientFill(getShape(getThis() TSRMLS_CC), getGradient(arg1 TSRMLS_CC), flags);
5398 } else if (Z_OBJCE_P(arg1) == bitmap_class_entry_ptr) {
5399 if (flags == 0) {
5400 flags = SWFFILL_TILED_BITMAP;
5401 }
5402 fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC), getBitmap(arg1 TSRMLS_CC), flags);
5403 } else {
5404 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Argument is not a bitmap nor a gradient");
5405 }
5406
5407 } else if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) {
5408 /* it's a solid fill */
5409 zend_long r, g, b, a = 0xff;
5410
5411 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) {
5412 return;
5413 }
5414
5415 fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a);
5416 } else {
5417 WRONG_PARAM_COUNT;
5418 }
5419
5420 if (!fill) {
5421 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding fill to shape");
5422 }
5423
5424 /* return an SWFFill object */
5425 object_init_ex(return_value, fill_class_entry_ptr);
5426 #if PHP_VERSION_ID >= 70000
5427 ret = zend_register_resource(fill, le_swffillp);
5428 add_property_resource(return_value, "fill", ret);
5429 ret->gc.refcount++;
5430 #else
5431 ret = zend_list_insert(fill, le_swffillp);
5432 add_property_resource(return_value, "fill", ret);
5433 zend_list_addref(ret);
5434 #endif
5435 }
5436 /* }}} */
5437
5438 /* {{{ proto void swfshape::setleftfill(int arg1 [, int g ,int b [,int a]])
5439 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. */
5440 PHP_METHOD(swfshape, setLeftFill)
5441 {
5442 zval *zfill;
5443 zend_long r, g, b, a = 0xff;
5444 SWFFill fill;
5445
5446 if (ZEND_NUM_ARGS() == 1) {
5447 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfill) == FAILURE) {
5448 return;
5449 }
5450 fill = getFill(zfill TSRMLS_CC);
5451 }
5452 else {
5453 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) {
5454 return;
5455 }
5456 fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a);
5457 }
5458
5459 SWFShape_setLeftFill(getShape(getThis() TSRMLS_CC), fill);
5460 }
5461 /* }}} */
5462
5463 /* {{{ proto void swfshape::setleftfill(int arg1 [, int g ,int b [,int a]])
5464 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. */
5465 PHP_METHOD(swfshape, setRightFill)
5466 {
5467 zval *zfill;
5468 zend_long r, g, b, a = 0xff;
5469 SWFFill fill;
5470
5471 if (ZEND_NUM_ARGS() == 1) {
5472 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfill) == FAILURE) {
5473 return;
5474 }
5475 fill = getFill(zfill TSRMLS_CC);
5476 }
5477 else {
5478 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) {
5479 return;
5480 }
5481 fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a);
5482 }
5483
5484 SWFShape_setRightFill(getShape(getThis() TSRMLS_CC), fill);
5485 }
5486 /* }}} */
5487
5488 /* {{{ proto void swfshape::movepento(double x, double y)
5489 Moves the pen to shape coordinates (x, y) */
5490 PHP_METHOD(swfshape, movePenTo)
5491 {
5492 double x, y;
5493
5494 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
5495 return;
5496 }
5497
5498 SWFShape_movePenTo(getShape(getThis() TSRMLS_CC), x, y);
5499 }
5500 /* }}} */
5501
5502 /* {{{ proto void swfshape::movepen(double x, double y)
5503 Moves the pen from its current location by vector (x, y) */
5504 PHP_METHOD(swfshape, movePen)
5505 {
5506 double x, y;
5507
5508 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
5509 return;
5510 }
5511
5512 SWFShape_movePen(getShape(getThis() TSRMLS_CC), x, y);
5513 }
5514 /* }}} */
5515
5516 /* {{{ proto void swfshape::drawlineto(double x, double y)
5517 Draws a line from the current pen position to shape coordinates (x, y) in the current line style */
5518 PHP_METHOD(swfshape, drawLineTo)
5519 {
5520 double x, y;
5521
5522 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
5523 return;
5524 }
5525
5526 SWFShape_drawLineTo(getShape(getThis() TSRMLS_CC), x, y);
5527 }
5528 /* }}} */
5529
5530 /* {{{ proto void swfshape::drawline(double dx, double dy)
5531 Draws a line from the current pen position (x, y) to the point (x+dx, y+dy) in the current line style */
5532 PHP_METHOD(swfshape, drawLine)
5533 {
5534 double x, y;
5535
5536 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
5537 return;
5538 }
5539
5540 SWFShape_drawLine(getShape(getThis() TSRMLS_CC), x, y);
5541 }
5542 /* }}} */
5543
5544 /* {{{ proto void swfshape::drawcurveto(double ax, double ay, double bx, double by [, double dx, double dy])
5545 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) */
5546 PHP_METHOD(swfshape, drawCurveTo)
5547 {
5548 if (ZEND_NUM_ARGS() == 4) {
5549 double cx, cy, ax, ay;
5550
5551 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &cx, &cy, &ax, &ay) == FAILURE) {
5552 return;
5553 }
5554
5555 SWFShape_drawCurveTo(getShape(getThis() TSRMLS_CC), cx, cy, ax, ay);
5556 } else if (ZEND_NUM_ARGS() == 6) {
5557 double bx, by, cx, cy, dx, dy;
5558
5559 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) {
5560 return;
5561 }
5562
5563 RETURN_LONG(SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy));
5564 } else {
5565 WRONG_PARAM_COUNT;
5566 }
5567 }
5568 /* }}} */
5569
5570 /* {{{ proto void swfshape::drawcurve(double adx, double ady, double bdx, double bdy [, double cdx, double cdy])
5571 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) */
5572 PHP_METHOD(swfshape, drawCurve)
5573 {
5574 if (ZEND_NUM_ARGS() == 4) {
5575 double cx, cy, ax, ay;
5576
5577 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &cx, &cy, &ax, &ay) == FAILURE) {
5578 return;
5579 }
5580
5581 SWFShape_drawCurve(getShape(getThis() TSRMLS_CC), cx, cy, ax, ay);
5582 } else if (ZEND_NUM_ARGS() == 6) {
5583 double bx, by, cx, cy, dx, dy;
5584
5585 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) {
5586 return;
5587 }
5588
5589 RETURN_LONG(SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy));
5590 } else {
5591 WRONG_PARAM_COUNT;
5592 }
5593 }
5594 /* }}} */
5595
5596 /* {{{ proto void swfshape::drawglyph(SWFFont font, string character [, int size])
5597 Draws the first character in the given string into the shape using the glyph definition from the given font */
5598 PHP_METHOD(swfshape, drawGlyph)
5599 {
5600 zval *font;
5601 char *c;
5602 zend_strlen c_len;
5603 zend_long size = (long)(1024.0f/Ming_getScale());
5604
5605 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os|l", &font, &c, &c_len, &size) == FAILURE) {
5606 return;
5607 }
5608 SWFShape_drawSizedGlyph(getShape(getThis() TSRMLS_CC), getFont(font TSRMLS_CC), c[0], size);
5609 }
5610 /* }}} */
5611
5612 /* {{{ proto void swfshape::drawcircle(double r)
5613 Draws a circle of radius r centered at the current location, in a counter-clockwise fashion */
5614 PHP_METHOD(swfshape, drawCircle)
5615 {
5616 double r;
5617
5618 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &r) == FAILURE) {
5619 return;
5620 }
5621
5622 SWFShape_drawCircle(getShape(getThis() TSRMLS_CC), r);
5623 }
5624 /* }}} */
5625
5626 /* {{{ proto void swfshape::drawarc(double r, double startAngle, double endAngle)
5627 Draws an arc of radius r centered at the current location, from angle startAngle to angle endAngle measured clockwise from 12 o'clock */
5628 PHP_METHOD(swfshape, drawArc)
5629 {
5630 double r, start, end;
5631
5632 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &r, &start, &end) == FAILURE) {
5633 return;
5634 }
5635
5636 /* convert angles to radians, since that's what php uses elsewhere */
5637 SWFShape_drawArc(getShape(getThis() TSRMLS_CC), r, start, end);
5638 }
5639 /* }}} */
5640
5641 /* {{{ proto void swfshape::drawcubic(double bx, double by, double cx, double cy, double dx, double dy)
5642 Draws a cubic bezier curve using the current position and the three given points as control points */
5643 PHP_METHOD(swfshape, drawCubic)
5644 {
5645 double bx, by, cx, cy, dx, dy;
5646
5647 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) {
5648 return;
5649 }
5650
5651 RETURN_LONG(SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy));
5652 }
5653 /* }}} */
5654
5655 /* {{{ proto void swfshape::drawcubic(double bx, double by, double cx, double cy, double dx, double dy)
5656 Draws a cubic bezier curve using the current position and the three given points as control points */
5657 PHP_METHOD(swfshape, drawCubicTo)
5658 {
5659 double bx, by, cx, cy, dx, dy;
5660
5661 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) {
5662 return;
5663 }
5664
5665 RETURN_LONG(SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy));
5666 }
5667 /* }}} */
5668
5669 /* {{{ proto void swfshape::end() */
5670 PHP_METHOD(swfshape, end)
5671 {
5672 if (ZEND_NUM_ARGS() != 0) {
5673 WRONG_PARAM_COUNT;
5674 }
5675
5676 SWFShape_end(getShape(getThis() TSRMLS_CC));
5677 }
5678 /* }}} */
5679
5680 /* {{{ proto void swfshape::useVersion()
5681 * SWF_SHAPE3
5682 * SWF_SHAPE4
5683 */
5684 PHP_METHOD(swfshape, useVersion)
5685 {
5686 zend_long ver;
5687
5688 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ver) == FAILURE) {
5689 return;
5690 }
5691
5692 SWFShape_useVersion(getShape(getThis() TSRMLS_CC), ver);
5693 }
5694 /* }}} */
5695
5696 /* {{{ proto int swfshape::getVersion() */
5697 PHP_METHOD(swfshape, getVersion)
5698 {
5699 if (ZEND_NUM_ARGS() != 0) {
5700 WRONG_PARAM_COUNT;
5701 }
5702
5703 RETURN_LONG(SWFShape_getVersion(getShape(getThis() TSRMLS_CC)));
5704 }
5705 /* }}} */
5706
5707 /* {{{ proto void swfshape::setRenderHintingFlags(flags)
5708 * SWF_SHAPE_USESCALINGSTROKES
5709 * SWF_SHAPE_USENONSCALINGSTROKES
5710 */
5711 PHP_METHOD(swfshape, setRenderHintingFlags)
5712 {
5713 zend_long flags;
5714
5715 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) {
5716 return;
5717 }
5718
5719 SWFShape_setRenderHintingFlags(getShape(getThis() TSRMLS_CC), flags);
5720 }
5721 /* }}} */
5722
5723 /* {{{ proto double swfshape::getPenX() */
5724 PHP_METHOD(swfshape, getPenX)
5725 {
5726 if (ZEND_NUM_ARGS() != 0) {
5727 WRONG_PARAM_COUNT;
5728 }
5729
5730 RETURN_DOUBLE(SWFShape_getPenX(getShape(getThis() TSRMLS_CC)));
5731 }
5732 /* }}} */
5733
5734 /* {{{ proto double swfshape::getPenY() */
5735 PHP_METHOD(swfshape, getPenY)
5736 {
5737 if (ZEND_NUM_ARGS() != 0) {
5738 WRONG_PARAM_COUNT;
5739 }
5740
5741 RETURN_DOUBLE(SWFShape_getPenY(getShape(getThis() TSRMLS_CC)));
5742 }
5743 /* }}} */
5744
5745 /* {{{ proto void swfshape::hideLine() */
5746 PHP_METHOD(swfshape, hideLine)
5747 {
5748 if (ZEND_NUM_ARGS() != 0) {
5749 WRONG_PARAM_COUNT;
5750 }
5751
5752 SWFShape_hideLine(getShape(getThis() TSRMLS_CC));
5753 }
5754 /* }}} */
5755
5756 /* {{{ proto void swfshape::drawCharacterBounds(character) */
5757 PHP_METHOD(swfshape, drawCharacterBounds)
5758 {
5759 zval *character;
5760
5761 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &character) == FAILURE) {
5762 return;
5763 }
5764
5765 SWFShape_drawCharacterBounds(getShape(getThis() TSRMLS_CC),
5766 getCharacter(character TSRMLS_CC));
5767 }
5768 /* }}} */
5769
5770 /* {{{ proto void swfshape::setLine2(width, flags, miterLimit, r, g, b, [a])
5771 * Line cap style: select one of the following flags (default is round cap style)
5772 * SWF_LINESTYLE_CAP_ROUND
5773 * SWF_LINESTYLE_CAP_NONE
5774 * SWF_LINESTYLE_CAP_SQUARE
5775 *
5776 * Line join style: select one of the following flags (default is round join style)
5777 * SWF_LINESTYLE_JOIN_ROUND
5778 * SWF_LINESTYLE_JOIN_BEVEL
5779 * SWF_LINESTYLE_JOIN_MITER
5780 *
5781 * Scaling flags: disable horizontal / vertical scaling
5782 * SWF_LINESTYLE_FLAG_NOHSCALE
5783 * SWF_LINESTYLE_FLAG_NOVSCALE
5784 *
5785 * Enable pixel hinting to correct blurry vertical / horizontal lines
5786 * -> all anchors will be aligned to full pixels
5787 * SWF_LINESTYLE_FLAG_HINTING
5788 *
5789 * Disable stroke closure: if no-close flag is set caps will be applied
5790 * instead of joins
5791 * SWF_LINESTYLE_FLAG_NOCLOSE
5792 *
5793 * End-cap style: default round
5794 * SWF_LINESTYLE_FLAG_ENDCAP_ROUND
5795 * SWF_LINESTYLE_FLAG_ENDCAP_NONE
5796 * SWF_LINESTYLE_FLAG_ENDCAP_SQUARE
5797 *
5798 * If join style is SWF_LINESTYLE_JOIN_MITER a miter limit factor
5799 * must be set. Miter max length is then calculated as:
5800 * max miter len = miter limit * width.
5801 * If join style is not miter, this value will be ignored.
5802 * */
5803 PHP_METHOD(swfshape, setLine2)
5804 {
5805 zend_long width, flags, r, g, b, a = 0xff;
5806 double limit;
5807
5808 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lldlll|l", &width, &flags, &limit, &r, &g, &b, &a) == FAILURE) {
5809 return;
5810 }
5811
5812 SWFShape_setLine2(getShape(getThis() TSRMLS_CC), width, r, g, b, a, flags, limit);
5813 }
5814 /* }}} */
5815
5816 /* {{{ proto void swfshape::setLine2Filled(width, fill, flags, limit)
5817 * Line cap style: select one of the following flags (default is round cap style)
5818 * SWF_LINESTYLE_CAP_ROUND
5819 * SWF_LINESTYLE_CAP_NONE
5820 * SWF_LINESTYLE_CAP_SQUARE
5821 *
5822 * Line join style: select one of the following flags (default is round join style)
5823 * SWF_LINESTYLE_JOIN_ROUND
5824 * SWF_LINESTYLE_JOIN_BEVEL
5825 * SWF_LINESTYLE_JOIN_MITER
5826 *
5827 * Scaling flags: disable horizontal / vertical scaling
5828 * SWF_LINESTYLE_FLAG_NOHSCALE
5829 * SWF_LINESTYLE_FLAG_NOVSCALE
5830 *
5831 * Enable pixel hinting to correct blurry vertical / horizontal lines
5832 * -> all anchors will be aligned to full pixels
5833 * SWF_LINESTYLE_FLAG_HINTING
5834 *
5835 * Disable stroke closure: if no-close flag is set caps will be applied
5836 * instead of joins
5837 * SWF_LINESTYLE_FLAG_NOCLOSE
5838 *
5839 * End-cap style: default round
5840 * SWF_LINESTYLE_FLAG_ENDCAP_ROUND
5841 * SWF_LINESTYLE_FLAG_ENDCAP_NONE
5842 * SWF_LINESTYLE_FLAG_ENDCAP_SQUARE
5843 *
5844 * If join style is SWF_LINESTYLE_JOIN_MITER a miter limit factor
5845 * must be set. Miter max length is then calculated as:
5846 * max miter len = miter limit * width.
5847 * If join style is not miter, this value will be ignored.
5848 */
5849 PHP_METHOD(swfshape, setLine2Filled)
5850 {
5851 zend_long width, flags;
5852 zval *fill;
5853 double limit;
5854 SWFFill xfill;
5855
5856 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lold", &width, &fill, &flags, &limit) == FAILURE) {
5857 return;
5858 }
5859
5860 xfill = getFill(fill TSRMLS_CC);
5861 SWFShape_setLine2Filled(getShape(getThis() TSRMLS_CC), width, SWFFill_getFillStyle(xfill), flags, limit);
5862 }
5863 /* }}} */
5864
5865 /* {{{ */
5866 PHP_METHOD(swfshape, dumpOutline)
5867 {
5868 char *out;
5869 if (ZEND_NUM_ARGS() != 0) {
5870 WRONG_PARAM_COUNT;
5871 }
5872
5873 out = SWFShape_dumpOutline(getShape(getThis() TSRMLS_CC));
5874 #if PHP_VERSION_ID >= 70000
5875 RETURN_STRING(out);
5876 #else
5877 RETURN_STRING(out, 1);
5878 #endif
5879 free(out);
5880 }
5881 /* }}} */
5882
5883 static zend_function_entry swfshape_functions[] = {
5884 PHP_ME(swfshape, __construct, NULL, 0)
5885 PHP_ME(swfshape, setLine, NULL, 0)
5886 PHP_ME(swfshape, addFill, NULL, 0)
5887 PHP_ME(swfshape, addSolidFill, NULL, 0)
5888 PHP_ME(swfshape, addBitmapFill, NULL, 0)
5889 PHP_ME(swfshape, addGradientFill, NULL, 0)
5890 PHP_ME(swfshape, setLeftFill, NULL, 0)
5891 PHP_ME(swfshape, setRightFill, NULL, 0)
5892 PHP_ME(swfshape, movePenTo, NULL, 0)
5893 PHP_ME(swfshape, movePen, NULL, 0)
5894 PHP_ME(swfshape, drawLineTo, NULL, 0)
5895 PHP_ME(swfshape, drawLine, NULL, 0)
5896 PHP_ME(swfshape, drawCurveTo, NULL, 0)
5897 PHP_ME(swfshape, drawCurve, NULL, 0)
5898 PHP_ME(swfshape, drawGlyph, NULL, 0)
5899 PHP_ME(swfshape, drawCircle, NULL, 0)
5900 PHP_ME(swfshape, drawArc, NULL, 0)
5901 PHP_ME(swfshape, drawCubic, NULL, 0)
5902 PHP_ME(swfshape, drawCubicTo, NULL, 0)
5903 PHP_ME(swfshape, end, NULL, 0)
5904 PHP_ME(swfshape, useVersion, NULL, 0)
5905 PHP_ME(swfshape, setRenderHintingFlags, NULL, 0)
5906 PHP_ME(swfshape, getPenX, NULL, 0)
5907 PHP_ME(swfshape, getPenY, NULL, 0)
5908 PHP_ME(swfshape, hideLine, NULL, 0)
5909 PHP_ME(swfshape, drawCharacterBounds, NULL, 0)
5910 PHP_ME(swfshape, setLine2, NULL, 0)
5911 PHP_ME(swfshape, setLine2Filled, NULL, 0)
5912 PHP_ME(swfshape, dumpOutline, NULL, 0)
5913 { NULL, NULL, NULL }
5914 };
5915
5916 /* }}} */
5917
5918 /* {{{ SWFSprite
5919 */
5920 /* {{{ proto void swfsprite::__construct()
5921 Creates a new SWFSprite object */
5922 PHP_METHOD(swfsprite, __construct)
5923 {
5924 SWFMovieClip sprite = newSWFMovieClip();
5925 #if PHP_VERSION_ID >= 70000
5926 zend_resource *ret = zend_register_resource(sprite, le_swfspritep);
5927
5928 add_property_resource(getThis(), "sprite", ret);
5929 #else
5930 int ret = zend_list_insert(sprite, le_swfspritep);
5931
5932 object_init_ex(getThis(), sprite_class_entry_ptr);
5933 add_property_resource(getThis(), "sprite", ret);
5934 zend_list_addref(ret);
5935 #endif
5936 }
5937
5938 #if PHP_VERSION_ID >= 70000
5939 static void destroy_SWFSprite_resource(zend_resource *resource)
5940 #else
5941 static void destroy_SWFSprite_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
5942 #endif
5943 {
5944 destroySWFMovieClip((SWFMovieClip)resource->ptr);
5945 }
5946 /* }}} */
5947
5948 /* {{{ internal function SWFSprite getSprite(zval *id)
5949 Returns the SWFSprite object in zval *id */
5950 static SWFMovieClip getSprite(zval *id TSRMLS_DC)
5951 {
5952 void *sprite = SWFgetProperty(id, "sprite", 6, le_swfspritep TSRMLS_CC);
5953
5954 if (!sprite) {
5955 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFSprite");
5956 }
5957 return (SWFMovieClip)sprite;
5958 }
5959 /* }}} */
5960
5961 /* {{{ proto object swfsprite::add(object SWFCharacter)
5962 Adds the character to the sprite, returns a displayitem object */
5963 PHP_METHOD(swfsprite, add)
5964 {
5965 zval *zchar;
5966 #if PHP_VERSION_ID >= 70000
5967 zend_resource *ret;
5968 #else
5969 int ret;
5970 #endif
5971 SWFBlock block;
5972 SWFDisplayItem item;
5973 SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
5974
5975 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) {
5976 return;
5977 }
5978
5979 if (Z_OBJCE_P(zchar) == action_class_entry_ptr) {
5980 block = (SWFBlock)getAction(zchar TSRMLS_CC);
5981 } else {
5982 block = (SWFBlock)getCharacter(zchar TSRMLS_CC);
5983 }
5984
5985 item = SWFMovieClip_add(sprite, block);
5986
5987 if (item != NULL) {
5988 /* try and create a displayitem object */
5989 object_init_ex(return_value, displayitem_class_entry_ptr);
5990 #if PHP_VERSION_ID >= 70000
5991 ret = zend_register_resource(item, le_swfdisplayitemp);
5992 add_property_resource(return_value, "displayitem", ret);
5993 ret->gc.refcount++;
5994 #else
5995 ret = zend_list_insert(item, le_swfdisplayitemp);
5996 add_property_resource(return_value, "displayitem", ret);
5997 zend_list_addref(ret);
5998 #endif
5999 }
6000 }
6001 /* }}} */
6002
6003 /* {{{ proto void swfsprite::remove(object SWFDisplayItem)
6004 Remove the named character from the sprite's display list */
6005 PHP_METHOD(swfsprite, remove)
6006 {
6007 zval *zchar;
6008 SWFDisplayItem item;
6009 SWFMovieClip movie = getSprite(getThis() TSRMLS_CC);
6010
6011 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) {
6012 return;
6013 }
6014
6015 item = getDisplayItem(zchar TSRMLS_CC);
6016 SWFMovieClip_remove(movie, item);
6017 }
6018 /* }}} */
6019
6020 /* {{{ proto void swfsprite::nextFrame()
6021 Moves the sprite to the next frame */
6022 PHP_METHOD(swfsprite, nextFrame)
6023 {
6024 SWFMovieClip_nextFrame(getSprite(getThis() TSRMLS_CC));
6025 }
6026 /* }}} */
6027
6028 /* {{{ proto void swfsprite::labelFrame(string label)
6029 Labels frame */
6030 PHP_METHOD(swfsprite, labelFrame)
6031 {
6032 char *label;
6033 zend_strlen label_len;
6034
6035 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &label, &label_len) == FAILURE) {
6036 return;
6037 }
6038
6039 SWFMovieClip_labelFrame(getSprite(getThis() TSRMLS_CC), label);
6040 }
6041 /* }}} */
6042
6043 /* {{{ proto void swfsprite::setFrames(int frames)
6044 Sets the number of frames in this SWFSprite */
6045 PHP_METHOD(swfsprite, setFrames)
6046 {
6047 zend_long frames;
6048 SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
6049
6050 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &frames) == FAILURE) {
6051 return;
6052 }
6053
6054 SWFMovieClip_setNumberOfFrames(sprite, frames);
6055 }
6056 /* }}} */
6057
6058 #ifdef HAVE_NEW_MING
6059 /* {{{ SWFSoundInstance swfsprite_startsound */
6060
6061 PHP_METHOD(swfsprite, startSound)
6062 {
6063 zval *zsound;
6064 #if PHP_VERSION_ID >= 70000
6065 zend_resource *ret;
6066 #else
6067 int ret;
6068 #endif
6069 SWFSound sound;
6070 SWFSoundInstance item;
6071 SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
6072
6073 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) {
6074 return;
6075 }
6076 sound = (SWFSound)getSound(zsound TSRMLS_CC);
6077
6078 item = SWFMovieClip_startSound(sprite, sound);
6079
6080 if(item != NULL) {
6081 /* try and create a displayitem object */
6082 object_init_ex(return_value, soundinstance_class_entry_ptr);
6083 #if PHP_VERSION_ID >= 70000
6084 ret = zend_register_resource(item, le_swfsoundinstancep);
6085 add_property_resource(return_value, "soundinstance", ret);
6086 ret->gc.refcount++;
6087 #else
6088 ret = zend_list_insert(item, le_swfsoundinstancep);
6089 add_property_resource(return_value, "soundinstance", ret);
6090 zend_list_addref(ret);
6091 #endif
6092 }
6093 }
6094
6095 /* }}} */
6096 /* {{{ void swfsprite_stopsound */
6097
6098 PHP_METHOD(swfsprite, stopSound)
6099 {
6100 zval *zsound;
6101 SWFSound sound;
6102 SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
6103
6104 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) {
6105 return;
6106 }
6107 sound = (SWFSound)getSound(zsound TSRMLS_CC);
6108
6109 SWFMovieClip_stopSound(sprite, sound);
6110 }
6111 /* }}} */
6112
6113 /* {{{ proto long swfmovieclip::setSoundStream(mixed file, rate[, skip])
6114 Sets sound stream of the SWF movieClip. The parameter can be stream or string. */
6115 PHP_METHOD(swfsprite, setSoundStream)
6116 {
6117 zval *zfile;
6118 double rate, skip = 0;
6119 SWFSoundStream sound = NULL;
6120 SWFInput input = NULL;
6121 SWFMovieClip mc = getSprite(getThis() TSRMLS_CC);
6122
6123 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zd|d", &zfile, &rate, &skip) == FAILURE) {
6124 return;
6125 }
6126
6127 switch(Z_TYPE_P(zfile))
6128 {
6129 case IS_RESOURCE:
6130 input = getInput_fromFileResource(zfile TSRMLS_CC);
6131 break;
6132 case IS_OBJECT:
6133 if ( isInput(zfile TSRMLS_CC) )
6134 {
6135 input = getInput(zfile TSRMLS_CC);
6136 }
6137 else
6138 {
6139 sound = getSoundStream(zfile TSRMLS_CC);
6140 }
6141 break;
6142 case IS_STRING:
6143 input = newSWFInput_filename(Z_STRVAL_P(zfile));
6144 if(input == NULL)
6145 php_error(E_ERROR, "opening sound file failed");
6146 #if PHP_VERSION_ID >= 70000
6147 zend_register_resource(input, le_swfinputp);
6148 #else
6149 zend_list_addref(zend_list_insert(input, le_swfinputp));
6150 #endif
6151 break;
6152
6153 }
6154
6155 if ( input ) {
6156 sound = newSWFSoundStream_fromInput(input);
6157 } else if ( ! sound ) {
6158 php_error(E_ERROR, "swfmovieclip::setSoundStream: "
6159 "need either a filename, "
6160 "a file ressource, "
6161 "an SWFInput buffer or an SWFSoundStream");
6162 }
6163 SWFMovieClip_setSoundStreamAt(mc, sound, rate, skip);
6164 RETURN_LONG(SWFSoundStream_getDuration(sound) / rate);
6165 }
6166 /* }}} */
6167
6168
6169 /* {{{ proto void swfsprite::setScalingGrid(int x, int y, int w, int h) */
6170 PHP_METHOD(swfsprite, setScalingGrid)
6171 {
6172 zend_long zx, zy, zw, zh;
6173 SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
6174
6175 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &zx, &zy, &zw, &zh) == FAILURE) {
6176 return;
6177 }
6178
6179 SWFMovieClip_setScalingGrid(sprite, zx, zy, zw, zh);
6180 }
6181 /* }}} */
6182
6183 /* {{{ proto void swfsprite::removeScalingGrid() */
6184 PHP_METHOD(swfsprite, removeScalingGrid)
6185 {
6186 SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
6187 if (ZEND_NUM_ARGS() != 0) {
6188 WRONG_PARAM_COUNT;
6189 }
6190
6191 SWFMovieClip_removeScalingGrid(sprite);
6192 }
6193 /* }}} */
6194
6195 /* {{{ proto void swfsprite::addInitAction(action) */
6196 PHP_METHOD(swfsprite, addInitAction)
6197 {
6198 zval *zaction;
6199
6200 SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
6201 SWFAction action;
6202
6203 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zaction) == FAILURE) {
6204 return;
6205 }
6206
6207 action = getAction(zaction TSRMLS_CC);
6208 SWFMovieClip_addInitAction(sprite, action);
6209 }
6210 /* }}} */
6211 #endif
6212
6213 // workaround to support SWFSprite and SWFMovieclip objects
6214 static zend_function_entry swfmovieclip_functions[] = {
6215 PHP_ME(swfsprite, __construct, NULL, 0)
6216 PHP_ME(swfsprite, add, NULL, 0)
6217 PHP_ME(swfsprite, remove, NULL, 0)
6218 PHP_ME(swfsprite, nextFrame, NULL, 0)
6219 PHP_ME(swfsprite, labelFrame, NULL, 0)
6220 PHP_ME(swfsprite, setFrames, NULL, 0)
6221 #ifdef HAVE_NEW_MING
6222 PHP_ME(swfsprite, startSound, NULL, 0)
6223 PHP_ME(swfsprite, stopSound, NULL, 0)
6224 PHP_ME(swfsprite, setScalingGrid, NULL, 0)
6225 PHP_ME(swfsprite, removeScalingGrid, NULL, 0)
6226 PHP_ME(swfsprite, setSoundStream, NULL, 0)
6227 PHP_ME(swfsprite, addInitAction, NULL, 0)
6228 #endif
6229 { NULL, NULL, NULL }
6230 };
6231
6232 static zend_function_entry swfsprite_functions[] = {
6233 PHP_ME(swfsprite, __construct, NULL, 0)
6234 PHP_ME(swfsprite, add, NULL, 0)
6235 PHP_ME(swfsprite, remove, NULL, 0)
6236 PHP_ME(swfsprite, nextFrame, NULL, 0)
6237 PHP_ME(swfsprite, labelFrame, NULL, 0)
6238 PHP_ME(swfsprite, setFrames, NULL, 0)
6239 #ifdef HAVE_NEW_MING
6240 PHP_ME(swfsprite, startSound, NULL, 0)
6241 PHP_ME(swfsprite, stopSound, NULL, 0)
6242 PHP_ME(swfsprite, setScalingGrid, NULL, 0)
6243 PHP_ME(swfsprite, removeScalingGrid, NULL, 0)
6244 PHP_ME(swfsprite, setSoundStream, NULL, 0)
6245 PHP_ME(swfsprite, addInitAction, NULL, 0)
6246 #endif
6247 { NULL, NULL, NULL }
6248 };
6249
6250 /* }}} */
6251
6252 /* {{{ SWFText
6253 */
6254 /* {{{ proto void swftext::__construct([version])
6255 Creates new SWFText object */
6256 PHP_METHOD(swftext, __construct)
6257 {
6258 zend_long version = 0;
6259 SWFText text;
6260
6261 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &version) == FAILURE) {
6262 return;
6263 }
6264 if (version == 1) {
6265 text = newSWFText();
6266 }
6267 else {
6268 text = newSWFText2();
6269 }
6270
6271 #if PHP_VERSION_ID >= 70000
6272 zend_resource *ret = zend_register_resource(text, le_swftextp);
6273 add_property_resource(getThis(), "text", ret);
6274 #else
6275 int ret = zend_list_insert(text, le_swftextp);
6276 object_init_ex(getThis(), text_class_entry_ptr);
6277 add_property_resource(getThis(), "text", ret);
6278 zend_list_addref(ret);
6279 #endif
6280 }
6281
6282 #if PHP_VERSION_ID >= 70000
6283 static void destroy_SWFText_resource(zend_resource *resource)
6284 #else
6285 static void destroy_SWFText_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
6286 #endif
6287 {
6288 destroySWFText((SWFText)resource->ptr);
6289 }
6290 /* }}} */
6291
6292 /* {{{ internal function SWFText getText(zval *id)
6293 Returns the SWFText contained in zval *id */
6294 static SWFText getText(zval *id TSRMLS_DC)
6295 {
6296 void *text = SWFgetProperty(id, "text", 4, le_swftextp TSRMLS_CC);
6297
6298 if (!text) {
6299 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFText");
6300 }
6301 return (SWFText)text;
6302 }
6303 /* }}} */
6304
6305 /* {{{ proto void swftext::setFont(SWFFont font)
6306 Sets this SWFText object's current font to given font */
6307 PHP_METHOD(swftext, setFont)
6308 {
6309 zval *zfont;
6310 SWFText text = getText(getThis() TSRMLS_CC);
6311 SWFFont font;
6312
6313 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfont) == FAILURE) {
6314 return;
6315 }
6316
6317 font = getFont(zfont TSRMLS_CC);
6318 SWFText_setFont(text, font);
6319 }
6320 /* }}} */
6321
6322 /* {{{ proto void swftext::setHeight(float height)
6323 Sets this SWFText object's current height to given height */
6324 PHP_METHOD(swftext, setHeight)
6325 {
6326 double height;
6327 SWFText text = getText(getThis() TSRMLS_CC);
6328
6329 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &height) == FAILURE) {
6330 return;
6331 }
6332
6333 SWFText_setHeight(text, height);
6334 }
6335 /* }}} */
6336
6337 /* {{{ proto void swftext::setSpacing(float spacing)
6338 Sets this SWFText object's current letterspacing to given spacing */
6339 PHP_METHOD(swftext, setSpacing)
6340 {
6341 double spacing;
6342 SWFText text = getText(getThis() TSRMLS_CC);
6343
6344 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &spacing) == FAILURE) {
6345 return;
6346 }
6347
6348 SWFText_setSpacing(text, spacing);
6349 }
6350 /* }}} */
6351
6352 /* {{{ proto void swftext::setColor(int r, int g, int b [, int a])
6353 Sets this SWFText object's current color to the given color */
6354 PHP_METHOD(swftext, setColor)
6355 {
6356 zend_long r, g, b, a = 0xff;
6357 SWFText text = getText(getThis() TSRMLS_CC);
6358
6359 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) {
6360 return;
6361 }
6362
6363 SWFText_setColor(text, (byte)r, (byte)g, (byte)b, (byte)a);
6364 }
6365 /* }}} */
6366
6367 /* {{{ proto void swftext::moveTo(float x, float y)
6368 Moves this SWFText object's current pen position to (x, y) in text coordinates */
6369 PHP_METHOD(swftext, moveTo)
6370 {
6371 double x, y;
6372 SWFText text = getText(getThis() TSRMLS_CC);
6373
6374 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
6375 return;
6376 }
6377
6378 SWFText_setXY(text, x, y);
6379 }
6380 /* }}} */
6381
6382 /* {{{ proto void swftext::addString(string text)
6383 Writes the given text into this SWFText object at the current pen position, using the current font, height, spacing, and color */
6384 PHP_METHOD(swftext, addString)
6385 {
6386 char *s;
6387 zend_strlen s_len;
6388 SWFText text = getText(getThis() TSRMLS_CC);
6389
6390 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &s_len) == FAILURE) {
6391 return;
6392 }
6393
6394 SWFText_addString(text, s, NULL);
6395 }
6396 /* }}} */
6397
6398 #ifdef HAVE_NEW_MING
6399 /* {{{ proto void swftext::addUTF8String(string text)
6400 Writes the given text into this SWFText object at the current pen position,
6401 using the current font, height, spacing, and color */
6402
6403 PHP_METHOD(swftext, addUTF8String)
6404 {
6405 char *s;
6406 zend_strlen s_len;
6407 SWFText text = getText(getThis() TSRMLS_CC);
6408
6409 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &s_len) == FAILURE) {
6410 return;
6411 }
6412
6413 SWFText_addUTF8String(text, s, NULL);
6414 }
6415
6416 /* }}} */
6417 /* {{{ proto void swftext::addWideString(string text)
6418 Writes the given text into this SWFText object at the current pen position,
6419 using the current font, height, spacing, and color */
6420 /*
6421 PHP_METHOD(swftext, addWideString)
6422 {
6423 char *s;
6424 zend_strlen s_len;
6425 SWFText text = getText(getThis() TSRMLS_CC);
6426
6427 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &s_len) == FAILURE) {
6428 return;
6429 }
6430
6431 SWFText_addWideString(text, s, NULL);
6432 }
6433 */
6434 /* }}} */
6435 #endif
6436
6437 /* {{{ proto float swftext::getWidth(string str)
6438 Calculates the width of the given string in this text objects current font and size */
6439 PHP_METHOD(swftext, getWidth)
6440 {
6441 char *string;
6442 zend_strlen string_len;
6443
6444 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
6445 return;
6446 }
6447
6448 RETURN_DOUBLE(SWFText_getStringWidth(getText(getThis() TSRMLS_CC), string));
6449 }
6450 /* }}} */
6451
6452 #ifdef HAVE_NEW_MING
6453 /* {{{ proto double swftext::getUTF8Width(string)
6454 calculates the width of the given string in this text objects current font and size */
6455
6456 PHP_METHOD(swftext, getUTF8Width)
6457 {
6458 char *string;
6459 zend_strlen string_len;
6460
6461 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
6462 return;
6463 }
6464
6465 RETURN_DOUBLE(SWFText_getUTF8StringWidth(getText(getThis() TSRMLS_CC), string));
6466 }
6467
6468 /* }}} */
6469 /* {{{ proto double swftext::getWideWidth(string)
6470 calculates the width of the given string in this text objects current font and size */
6471 /*
6472 PHP_METHOD(swftext, getWideWidth)
6473 {
6474 char *string;
6475 zend_strlen string_len;
6476
6477 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
6478 return;
6479 }
6480
6481 RETURN_DOUBLE(SWFText_getWideStringWidth(getText(getThis() TSRMLS_CC), string));
6482 }
6483 */
6484 /* }}} */
6485 #endif
6486
6487 /* {{{ proto float swftext::getAscent()
6488 Returns the ascent of the current font at its current size, or 0 if not available */
6489 PHP_METHOD(swftext, getAscent)
6490 {
6491 if(ZEND_NUM_ARGS() != 0) {
6492 WRONG_PARAM_COUNT;
6493 }
6494 RETURN_DOUBLE(SWFText_getAscent(getText(getThis() TSRMLS_CC)));
6495 }
6496 /* }}} */
6497
6498 /* {{{ proto float swftext::getDescent()
6499 Returns the descent of the current font at its current size, or 0 if not available */
6500 PHP_METHOD(swftext, getDescent)
6501 {
6502 if(ZEND_NUM_ARGS() != 0) {
6503 WRONG_PARAM_COUNT;
6504 }
6505 RETURN_DOUBLE(SWFText_getDescent(getText(getThis() TSRMLS_CC)));
6506 }
6507 /* }}} */
6508
6509 /* {{{ proto float swftext::getLeading()
6510 Returns the leading of the current font at its current size, or 0 if not available */
6511 PHP_METHOD(swftext, getLeading)
6512 {
6513 if(ZEND_NUM_ARGS() != 0) {
6514 WRONG_PARAM_COUNT;
6515 }
6516 RETURN_DOUBLE(SWFText_getLeading(getText(getThis() TSRMLS_CC)));
6517 }
6518 /* }}} */
6519
6520 static zend_function_entry swftext_functions[] = {
6521 PHP_ME(swftext, __construct, NULL, 0)
6522 PHP_ME(swftext, setFont, NULL, 0)
6523 PHP_ME(swftext, setHeight, NULL, 0)
6524 PHP_ME(swftext, setSpacing, NULL, 0)
6525 PHP_ME(swftext, setColor, NULL, 0)
6526 PHP_ME(swftext, moveTo, NULL, 0)
6527 PHP_ME(swftext, addString, NULL, 0)
6528 #ifdef HAVE_NEW_MING
6529 PHP_ME(swftext, addUTF8String, NULL, 0)
6530 /* PHP_ME(swftext, addwidestring, NULL, 0)*/
6531 #endif
6532 PHP_ME(swftext, getWidth, NULL, 0)
6533 #ifdef HAVE_NEW_MING
6534 PHP_ME(swftext, getUTF8Width, NULL, 0)
6535 /* PHP_ME(swftext, getwidewidth, NULL, 0)*/
6536 #endif
6537 PHP_ME(swftext, getAscent, NULL, 0)
6538 PHP_ME(swftext, getDescent, NULL, 0)
6539 PHP_ME(swftext, getLeading, NULL, 0)
6540 { NULL, NULL, NULL }
6541 };
6542
6543 /* }}} */
6544
6545 /* {{{ SWFTextField
6546 */
6547 /* {{{ proto void swftextfield::__construct([int flags])
6548 Creates a new SWFTextField object */
6549 PHP_METHOD(swftextfield, __construct)
6550 {
6551 zend_long flags = 0;
6552 SWFTextField field = newSWFTextField();
6553 #if PHP_VERSION_ID >= 70000
6554 zend_resource *ret = zend_register_resource(field, le_swftextfieldp);
6555
6556 add_property_resource(getThis(), "textfield", ret);
6557 #else
6558 int ret = zend_list_insert(field, le_swftextfieldp);
6559
6560 object_init_ex(getThis(), textfield_class_entry_ptr);
6561 add_property_resource(getThis(), "textfield", ret);
6562 zend_list_addref(ret);
6563 #endif
6564
6565 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
6566 return;
6567 }
6568
6569 SWFTextField_setFlags(field, flags);
6570 }
6571 /* }}} */
6572
6573 #if PHP_VERSION_ID >= 70000
6574 static void destroy_SWFTextField_resource(zend_resource *resource)
6575 #else
6576 static void destroy_SWFTextField_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
6577 #endif
6578 {
6579 destroySWFTextField((SWFTextField)resource->ptr);
6580 }
6581
6582 /* {{{ internal function getTextField
6583 Returns the SWFTextField object contained in zval *id */
6584 static SWFTextField getTextField(zval *id TSRMLS_DC)
6585 {
6586 void *field = SWFgetProperty(id, "textfield", 9, le_swftextfieldp TSRMLS_CC);
6587
6588 if (!field) {
6589 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFTextField");
6590 }
6591 return (SWFTextField)field;
6592 }
6593 /* }}} */
6594
6595 /* {{{ proto void swftextfield::setFont(object font)
6596 Sets the font for this textfield */
6597 static
6598 SWFBlock getFontOrFontChar(zval *id TSRMLS_DC)
6599 {
6600 if(Z_OBJCE_P(id) == font_class_entry_ptr) {
6601 return (SWFBlock)getFont(id TSRMLS_CC);
6602 } else if(Z_OBJCE_P(id) == fontchar_class_entry_ptr) {
6603 return (SWFBlock)getFontCharacter(id TSRMLS_CC);
6604 } else {
6605 php_error(E_ERROR, "called object is not an SWFFont or SWFFontCharacter");
6606 }
6607 return NULL;
6608 }
6609
6610 PHP_METHOD(swftextfield, setFont)
6611 {
6612 zval *font;
6613 SWFTextField field = getTextField(getThis() TSRMLS_CC);
6614
6615 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &font) == FAILURE) {
6616 return;
6617 }
6618
6619 if(Z_OBJCE_P(font) == font_class_entry_ptr
6620 || Z_OBJCE_P(font) == fontchar_class_entry_ptr)
6621 {
6622 SWFTextField_setFont(field, getFontOrFontChar(font TSRMLS_CC));
6623 }
6624 else if(Z_OBJCE_P(font) == browserfont_class_entry_ptr)
6625 {
6626 SWFTextField_setFont(field, (SWFBlock)getBrowserFont(font TSRMLS_CC));
6627 }
6628 else {
6629 php_error(E_ERROR, "not a font object\n");
6630 }
6631 }
6632 /* }}} */
6633
6634 /* {{{ proto void swftextfield::setBounds(float width, float height)
6635 Sets the width and height of this textfield */
6636 PHP_METHOD(swftextfield, setBounds)
6637 {
6638 double width, height;
6639
6640 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &width, &height) == FAILURE) {
6641 return;
6642 }
6643
6644 SWFTextField_setBounds(getTextField(getThis() TSRMLS_CC), width, height);
6645 }
6646 /* }}} */
6647
6648 /* {{{ proto void swftextfield::setFlags(int flags)
6649 Sets the flags for this textfield */
6650 PHP_METHOD(swftextfield, setFlags)
6651 {
6652 zend_long flags;
6653
6654 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
6655 return;
6656 }
6657
6658 SWFTextField_setFlags(getTextField(getThis() TSRMLS_CC), flags);
6659
6660 }
6661 /* }}} */
6662
6663 /* {{{ proto void swftextfield::align(int alignment)
6664 Sets the alignment of this textfield */
6665 PHP_METHOD(swftextfield, align)
6666 {
6667 zend_long align;
6668
6669 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &align) == FAILURE) {
6670 return;
6671 }
6672
6673 SWFTextField_setAlignment(getTextField(getThis() TSRMLS_CC), align);
6674 }
6675 /* }}} */
6676
6677 /* {{{ proto void swftextfield::setHeight(float height)
6678 Sets the font height of this textfield */
6679 PHP_METHOD(swftextfield, setHeight)
6680 {
6681 double height;
6682
6683 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &height) == FAILURE) {
6684 return;
6685 }
6686
6687 SWFTextField_setHeight(getTextField(getThis() TSRMLS_CC), height);
6688 }
6689 /* }}} */
6690
6691 /* {{{ proto void swftextfield::setLeftMargin(float margin)
6692 Sets the left margin of this textfield */
6693 PHP_METHOD(swftextfield, setLeftMargin)
6694 {
6695 double margin;
6696
6697 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &margin) == FAILURE) {
6698 return;
6699 }
6700
6701 SWFTextField_setLeftMargin(getTextField(getThis() TSRMLS_CC), margin);
6702 }
6703 /* }}} */
6704
6705 /* {{{ proto void swftextfield::setRightMargin(float margin)
6706 Sets the right margin of this textfield */
6707 PHP_METHOD(swftextfield, setRightMargin)
6708 {
6709 double margin;
6710
6711 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &margin) == FAILURE) {
6712 return;
6713 }
6714
6715 SWFTextField_setRightMargin(getTextField(getThis() TSRMLS_CC), margin);
6716 }
6717 /* }}} */
6718
6719 /* {{{ proto void swftextfield::setMargins(float left, float right)
6720 Sets both margins of this textfield */
6721 PHP_METHOD(swftextfield, setMargins)
6722 {
6723 double left, right;
6724 SWFTextField field = getTextField(getThis() TSRMLS_CC);
6725
6726 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &left, &right) == FAILURE) {
6727 return;
6728 }
6729
6730 SWFTextField_setLeftMargin(field, left);
6731 SWFTextField_setRightMargin(field, right);
6732 }
6733 /* }}} */
6734
6735 /* {{{ proto void swftextfield::setIndentation(float indentation)
6736 Sets the indentation of the first line of this textfield */
6737 PHP_METHOD(swftextfield, setIndentation)
6738 {
6739 double indent;
6740
6741 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &indent) == FAILURE) {
6742 return;
6743 }
6744
6745 SWFTextField_setIndentation(getTextField(getThis() TSRMLS_CC), indent);
6746 }
6747 /* }}} */
6748
6749 /* {{{ proto void swftextfield::setLineSpacing(float space)
6750 Sets the line spacing of this textfield */
6751 PHP_METHOD(swftextfield, setLineSpacing)
6752 {
6753 double spacing;
6754
6755 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &spacing) == FAILURE) {
6756 return;
6757 }
6758
6759 SWFTextField_setLineSpacing(getTextField(getThis() TSRMLS_CC), spacing);
6760 }
6761 /* }}} */
6762
6763 /* {{{ proto void swftextfield::setColor(int r, int g, int b [, int a])
6764 Sets the color of this textfield */
6765 PHP_METHOD(swftextfield, setColor)
6766 {
6767 zend_long r, g, b, a = 0xff;
6768
6769 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) {
6770 return;
6771 }
6772 SWFTextField_setColor(getTextField(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a);
6773 }
6774 /* }}} */
6775
6776 /* {{{ proto void swftextfield::setName(string var_name)
6777 Sets the variable name of this textfield */
6778 PHP_METHOD(swftextfield, setName)
6779 {
6780 char *name;
6781 zend_strlen name_len;
6782
6783 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
6784 return;
6785 }
6786
6787 SWFTextField_setVariableName(getTextField(getThis() TSRMLS_CC), name);
6788 }
6789 /* }}} */
6790
6791 /* {{{ proto void swftextfield::addString(string str)
6792 Adds the given string to this textfield */
6793 PHP_METHOD(swftextfield, addString)
6794 {
6795 char *str;
6796 zend_strlen str_len;
6797
6798 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
6799 return;
6800 }
6801
6802 SWFTextField_addString(getTextField(getThis() TSRMLS_CC), str);
6803 }
6804 /* }}} */
6805
6806 /* {{{ proto void swftextfield::addUTF8String(string str)
6807 Adds the given UTF8 string to this textfield */
6808 PHP_METHOD(swftextfield, addUTF8String)
6809 {
6810 char *str;
6811 zend_strlen str_len;
6812
6813 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
6814 return;
6815 }
6816
6817 SWFTextField_addUTF8String(getTextField(getThis() TSRMLS_CC), str);
6818 }
6819 /* }}} */
6820
6821
6822 #ifdef HAVE_NEW_MING
6823 /* {{{ proto void swftextfield::setPadding(float padding)
6824 Sets the padding of this textfield */
6825 PHP_METHOD(swftextfield, setPadding)
6826 {
6827 double padding;
6828
6829 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &padding) == FAILURE) {
6830 return;
6831 }
6832
6833 SWFTextField_setPadding(getTextField(getThis() TSRMLS_CC), padding);
6834 }
6835 /* }}} */
6836
6837 /* {{{ proto void swftextfield::addChars(string)
6838 adds characters to a font that will be available within a textfield */
6839 PHP_METHOD(swftextfield, addChars)
6840 {
6841 char *str;
6842 zend_strlen str_len;
6843
6844 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
6845 return;
6846 }
6847
6848 SWFTextField_addChars(getTextField(getThis() TSRMLS_CC), str);
6849
6850 }
6851 /* }}} */
6852
6853 /* {{{ proto void swftextfield::setLength(int len) */
6854 PHP_METHOD(swftextfield, setLength)
6855 {
6856 zend_long len;
6857
6858 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &len) == FAILURE) {
6859 return;
6860 }
6861
6862 SWFTextField_setLength(getTextField(getThis() TSRMLS_CC), len);
6863 }
6864 /* }}} */
6865
6866 /* {{{ proto void swftextfield::setLength(len) */
6867 PHP_METHOD(swftextfield, setFieldHeight)
6868 {
6869 zend_long h;
6870
6871 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &h) == FAILURE) {
6872 return;
6873 }
6874
6875 SWFTextField_setFieldHeight(getTextField(getThis() TSRMLS_CC), h);
6876 }
6877 /* }}} */
6878
6879 #endif
6880
6881 static zend_function_entry swftextfield_functions[] = {
6882 PHP_ME(swftextfield, __construct, NULL, 0)
6883 PHP_ME(swftextfield, setFont, NULL, 0)
6884 PHP_ME(swftextfield, setBounds, NULL, 0)
6885 PHP_ME(swftextfield, setFlags, NULL, 0)
6886 PHP_ME(swftextfield, align, NULL, 0)
6887 PHP_ME(swftextfield, setHeight, NULL, 0)
6888 PHP_ME(swftextfield, setLeftMargin, NULL, 0)
6889 PHP_ME(swftextfield, setRightMargin, NULL, 0)
6890 PHP_ME(swftextfield, setMargins, NULL, 0)
6891 PHP_ME(swftextfield, setIndentation, NULL, 0)
6892 PHP_ME(swftextfield, setLineSpacing, NULL, 0)
6893 PHP_ME(swftextfield, setColor, NULL, 0)
6894 PHP_ME(swftextfield, setName, NULL, 0)
6895 PHP_ME(swftextfield, addString, NULL, 0)
6896 PHP_ME(swftextfield, addUTF8String, NULL, 0)
6897 #ifdef HAVE_NEW_MING
6898 PHP_ME(swftextfield, setPadding, NULL, 0)
6899 PHP_ME(swftextfield, addChars, NULL, 0)
6900 PHP_ME(swftextfield, setLength, NULL, 0)
6901 PHP_ME(swftextfield, setFieldHeight, NULL, 0)
6902 #endif
6903 { NULL, NULL, NULL }
6904 };
6905
6906 /* }}} */
6907
6908 zend_module_entry ming_module_entry = {
6909 STANDARD_MODULE_HEADER,
6910 "ming",
6911 ming_functions,
6912 PHP_MINIT(ming), /* module init function */
6913 NULL, /* module shutdown function */
6914 PHP_RINIT(ming), /* request init function */
6915 NULL, /* request shutdown function */
6916 PHP_MINFO(ming), /* module info function */
6917 NO_VERSION_YET,
6918 STANDARD_MODULE_PROPERTIES
6919 };
6920
6921 #ifdef COMPILE_DL_MING
6922 ZEND_GET_MODULE(ming)
6923 #endif
6924
6925 /* {{{ todo PHP_MINFO_FUNCTION(ming)
6926 */
6927 PHP_MINFO_FUNCTION(ming)
6928 {
6929 php_info_print_table_start();
6930 php_info_print_table_row(2, "Ming SWF output library", "enabled");
6931 php_info_print_table_row(2, "Version", MING_VERSION_TEXT);
6932 php_info_print_table_end();
6933 }
6934 /* }}} */
6935
6936 #if PHP_API_VERSION == 20020918
6937 static php4_fix_funcnames(char *class_name, zend_function_entry *funcs) /* {{{ */
6938 {
6939 zend_function_entry *pf = funcs;
6940 char *pname;
6941
6942 while(funcs->fname) {
6943 if( strcmp(funcs->fname,"__construct") == 0 ) {
6944 pname=strdup(class_name);
6945 } else {
6946 pname=strdup(funcs->fname);
6947 }
6948 funcs->fname=pname;
6949 while(*pname) { *pname=tolower(*pname);pname++;}
6950 funcs++;
6951 }
6952 }
6953 /* }}} */
6954 #endif
6955
6956 /* custom error handler propagates ming errors up to php */
6957 static void php_ming_error(const char *msg, ...) /* {{{ */
6958 {
6959 va_list args;
6960 char *buffer;
6961
6962 TSRMLS_FETCH();
6963
6964 va_start(args, msg);
6965 vspprintf(&buffer, 0, msg, args);
6966 va_end(args);
6967
6968 php_error_docref(NULL TSRMLS_CC, E_ERROR, "%s", buffer);
6969 efree(buffer);
6970 }
6971 /* }}} */
6972
6973 PHP_RINIT_FUNCTION(ming) /* {{{ */
6974 {
6975 /* guard against repeated calls to Ming_init() */
6976 static int guard = 0;
6977 if ( guard ) {
6978 /* repeat previous success */
6979 return SUCCESS;
6980 }
6981
6982 if (Ming_init() != 0) {
6983 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error initializing Ming module");
6984 return FAILURE;
6985 }
6986 /* guard against repeated calls to Ming_init() */
6987 guard = 1;
6988 return SUCCESS;
6989 }
6990 /* }}} */
6991
6992 /* {{{ todo PHP_MINIT_FUNCTION(ming)
6993 */
6994 PHP_MINIT_FUNCTION(ming)
6995 {
6996 zend_class_entry shape_class_entry;
6997 zend_class_entry fill_class_entry;
6998 zend_class_entry gradient_class_entry;
6999 zend_class_entry bitmap_class_entry;
7000 zend_class_entry text_class_entry;
7001 zend_class_entry textfield_class_entry;
7002 zend_class_entry font_class_entry;
7003 zend_class_entry displayitem_class_entry;
7004 zend_class_entry movie_class_entry;
7005 zend_class_entry button_class_entry;
7006 zend_class_entry action_class_entry;
7007 zend_class_entry morph_class_entry;
7008 zend_class_entry movieclip_class_entry;
7009 zend_class_entry sprite_class_entry;
7010 zend_class_entry sound_class_entry;
7011 #ifdef HAVE_NEW_MING
7012 zend_class_entry fontchar_class_entry;
7013 zend_class_entry soundinstance_class_entry;
7014 zend_class_entry videostream_class_entry;
7015 zend_class_entry buttonrecord_class_entry;
7016 zend_class_entry binarydata_class_entry;
7017 zend_class_entry initaction_class_entry;
7018 zend_class_entry prebuiltclip_class_entry;
7019 zend_class_entry soundstream_class_entry;
7020 zend_class_entry filter_class_entry;
7021 zend_class_entry filtermatrix_class_entry;
7022 zend_class_entry blur_class_entry;
7023 zend_class_entry shadow_class_entry;
7024 zend_class_entry cxform_class_entry;
7025 zend_class_entry matrix_class_entry;
7026 zend_class_entry input_class_entry;
7027 zend_class_entry browserfont_class_entry;
7028 zend_class_entry fontcollection_class_entry;
7029 #endif
7030 zend_class_entry character_class_entry;
7031 Ming_setErrorFunction((void *) php_ming_error);
7032
7033 #define CONSTANT(s,c) REGISTER_LONG_CONSTANT((s), (c), CONST_CS | CONST_PERSISTENT)
7034
7035 #ifdef HAVE_NEW_MING
7036 CONSTANT("MING_NEW", 1);
7037 #else
7038 CONSTANT("MING_NEW", 0);
7039 #endif
7040 #ifdef HAVE_MING_ZLIB
7041 CONSTANT("MING_ZLIB", 1);
7042 #else
7043 CONSTANT("MING_ZLIB", 0);
7044 #endif
7045 /* flags for SWFButton_addShape */
7046 CONSTANT("SWFBUTTON_HIT", SWFBUTTONRECORD_HITSTATE);
7047 CONSTANT("SWFBUTTON_DOWN", SWFBUTTONRECORD_DOWNSTATE);
7048 CONSTANT("SWFBUTTON_OVER", SWFBUTTONRECORD_OVERSTATE);
7049 CONSTANT("SWFBUTTON_UP", SWFBUTTONRECORD_UPSTATE);
7050
7051 /* flags for SWFButton_addAction */
7052 CONSTANT("SWFBUTTON_MOUSEUPOUTSIDE", SWFBUTTON_MOUSEUPOUTSIDE);
7053 CONSTANT("SWFBUTTON_DRAGOVER", SWFBUTTON_DRAGOVER);
7054 CONSTANT("SWFBUTTON_DRAGOUT", SWFBUTTON_DRAGOUT);
7055 CONSTANT("SWFBUTTON_MOUSEUP", SWFBUTTON_MOUSEUP);
7056 CONSTANT("SWFBUTTON_MOUSEDOWN", SWFBUTTON_MOUSEDOWN);
7057 CONSTANT("SWFBUTTON_MOUSEOUT", SWFBUTTON_MOUSEOUT);
7058 CONSTANT("SWFBUTTON_MOUSEOVER", SWFBUTTON_MOUSEOVER);
7059
7060 /* flags for SWFFill */
7061 CONSTANT("SWFFILL_RADIAL_GRADIENT", SWFFILL_RADIAL_GRADIENT);
7062 CONSTANT("SWFFILL_LINEAR_GRADIENT", SWFFILL_LINEAR_GRADIENT);
7063 CONSTANT("SWFFILL_TILED_BITMAP", SWFFILL_TILED_BITMAP);
7064 CONSTANT("SWFFILL_CLIPPED_BITMAP", SWFFILL_CLIPPED_BITMAP);
7065 CONSTANT("SWFFILL_NONSMOOTHED_TILED_BITMAP",
7066 SWFFILL_NONSMOOTHED_TILED_BITMAP);
7067 CONSTANT("SWFFILL_NONSMOOTHED_CLIPPED_BITMAP",
7068 SWFFILL_NONSMOOTHED_CLIPPED_BITMAP);
7069
7070 /* flags for SWFTextField_init */
7071 CONSTANT("SWFTEXTFIELD_NOEDIT", SWFTEXTFIELD_NOEDIT);
7072 CONSTANT("SWFTEXTFIELD_PASSWORD", SWFTEXTFIELD_PASSWORD);
7073 CONSTANT("SWFTEXTFIELD_MULTILINE", SWFTEXTFIELD_MULTILINE);
7074 CONSTANT("SWFTEXTFIELD_WORDWRAP", SWFTEXTFIELD_WORDWRAP);
7075 CONSTANT("SWFTEXTFIELD_DRAWBOX", SWFTEXTFIELD_DRAWBOX);
7076 CONSTANT("SWFTEXTFIELD_NOSELECT", SWFTEXTFIELD_NOSELECT);
7077 CONSTANT("SWFTEXTFIELD_HTML", SWFTEXTFIELD_HTML);
7078 CONSTANT("SWFTEXTFIELD_AUTOSIZE", SWFTEXTFIELD_AUTOSIZE);
7079
7080 /* flags for SWFTextField_align */
7081 CONSTANT("SWFTEXTFIELD_ALIGN_LEFT", SWFTEXTFIELD_ALIGN_LEFT);
7082 CONSTANT("SWFTEXTFIELD_ALIGN_RIGHT", SWFTEXTFIELD_ALIGN_RIGHT);
7083 CONSTANT("SWFTEXTFIELD_ALIGN_CENTER", SWFTEXTFIELD_ALIGN_CENTER);
7084 CONSTANT("SWFTEXTFIELD_ALIGN_JUSTIFY", SWFTEXTFIELD_ALIGN_JUSTIFY);
7085
7086 /* flags for SWFDisplayItem_addAction */
7087 CONSTANT("SWFACTION_ONLOAD", SWFACTION_ONLOAD);
7088 CONSTANT("SWFACTION_ENTERFRAME", SWFACTION_ENTERFRAME);
7089 CONSTANT("SWFACTION_UNLOAD", SWFACTION_UNLOAD);
7090 CONSTANT("SWFACTION_MOUSEMOVE", SWFACTION_MOUSEMOVE);
7091 CONSTANT("SWFACTION_MOUSEDOWN", SWFACTION_MOUSEDOWN);
7092 CONSTANT("SWFACTION_MOUSEUP", SWFACTION_MOUSEUP);
7093 CONSTANT("SWFACTION_KEYDOWN", SWFACTION_KEYDOWN);
7094 CONSTANT("SWFACTION_KEYUP", SWFACTION_KEYUP);
7095 CONSTANT("SWFACTION_DATA", SWFACTION_DATA);
7096 CONSTANT("SWFACTION_INIT", SWFACTION_INIT);
7097 CONSTANT("SWFACTION_PRESS", SWFACTION_PRESS);
7098 CONSTANT("SWFACTION_RELEASE", SWFACTION_RELEASE);
7099 CONSTANT("SWFACTION_RELEASEOUTSIDE", SWFACTION_RELEASEOUTSIDE);
7100 CONSTANT("SWFACTION_ROLLOVER", SWFACTION_ROLLOVER);
7101 CONSTANT("SWFACTION_DRAGOVER", SWFACTION_DRAGOVER);
7102 CONSTANT("SWFACTION_DRAGOUT", SWFACTION_DRAGOUT);
7103 CONSTANT("SWFACTION_KEYPRESS", SWFACTION_KEYPRESS);
7104 CONSTANT("SWFACTION_CONSTRUCT", SWFACTION_CONSTRUCT);
7105
7106 /* flags for SWFSound */
7107 CONSTANT("SWF_SOUND_NOT_COMPRESSED", SWF_SOUND_NOT_COMPRESSED);
7108 CONSTANT("SWF_SOUND_ADPCM_COMPRESSED", SWF_SOUND_ADPCM_COMPRESSED);
7109 CONSTANT("SWF_SOUND_MP3_COMPRESSED", SWF_SOUND_MP3_COMPRESSED);
7110 CONSTANT("SWF_SOUND_NOT_COMPRESSED_LE", SWF_SOUND_NOT_COMPRESSED_LE);
7111 CONSTANT("SWF_SOUND_NELLY_COMPRESSED", SWF_SOUND_NELLY_COMPRESSED);
7112 CONSTANT("SWF_SOUND_5KHZ", SWF_SOUND_5KHZ);
7113 CONSTANT("SWF_SOUND_11KHZ", SWF_SOUND_11KHZ);
7114 CONSTANT("SWF_SOUND_22KHZ", SWF_SOUND_22KHZ);
7115 CONSTANT("SWF_SOUND_44KHZ", SWF_SOUND_44KHZ);
7116 CONSTANT("SWF_SOUND_8BITS", SWF_SOUND_8BITS);
7117 CONSTANT("SWF_SOUND_16BITS", SWF_SOUND_16BITS);
7118 CONSTANT("SWF_SOUND_MONO", SWF_SOUND_MONO);
7119 CONSTANT("SWF_SOUND_STEREO", SWF_SOUND_STEREO);
7120
7121 #ifdef HAVE_NEW_MING
7122 /* Blend Modes */
7123 CONSTANT("SWFBLEND_MODE_NORMAL", SWFBLEND_MODE_NORMAL);
7124 CONSTANT("SWFBLEND_MODE_LAYER", SWFBLEND_MODE_LAYER);
7125 CONSTANT("SWFBLEND_MODE_MULT", SWFBLEND_MODE_MULT);
7126 CONSTANT("SWFBLEND_MODE_SCREEN", SWFBLEND_MODE_SCREEN);
7127 CONSTANT("SWFBLEND_MODE_DARKEN", SWFBLEND_MODE_DARKEN);
7128 CONSTANT("SWFBLEND_MODE_LIGHTEN", SWFBLEND_MODE_LIGHTEN);
7129 CONSTANT("SWFBLEND_MODE_ADD", SWFBLEND_MODE_ADD);
7130 CONSTANT("SWFBLEND_MODE_SUB", SWFBLEND_MODE_SUB);
7131 CONSTANT("SWFBLEND_MODE_DIFF", SWFBLEND_MODE_DIFF);
7132 CONSTANT("SWFBLEND_MODE_INV", SWFBLEND_MODE_INV);
7133 CONSTANT("SWFBLEND_MODE_ALPHA", SWFBLEND_MODE_ALPHA);
7134 CONSTANT("SWFBLEND_MODE_ERASE", SWFBLEND_MODE_ERASE);
7135 CONSTANT("SWFBLEND_MODE_OVERLAY", SWFBLEND_MODE_OVERLAY);
7136 CONSTANT("SWFBLEND_MODE_HARDLIGHT", SWFBLEND_MODE_HARDLIGHT);
7137
7138 /* filter types */
7139 CONSTANT("SWFFILTER_TYPE_DROPSHADOW", SWFFILTER_TYPE_DROPSHADOW);
7140 CONSTANT("SWFFILTER_TYPE_BLUR", SWFFILTER_TYPE_BLUR);
7141 CONSTANT("SWFFILTER_TYPE_GLOW", SWFFILTER_TYPE_GLOW);
7142 CONSTANT("SWFFILTER_TYPE_BEVEL", SWFFILTER_TYPE_BEVEL);
7143 CONSTANT("SWFFILTER_TYPE_GRADIENTGLOW", SWFFILTER_TYPE_GRADIENTGLOW);
7144 CONSTANT("SWFFILTER_TYPE_CONVOLUTION", SWFFILTER_TYPE_CONVOLUTION);
7145 CONSTANT("SWFFILTER_TYPE_COLORMATRIX", SWFFILTER_TYPE_COLORMATRIX);
7146 CONSTANT("SWFFILTER_TYPE_GRADIENTBEVEL", SWFFILTER_TYPE_GRADIENTBEVEL);
7147
7148 /* filter flags */
7149 CONSTANT("SWFFILTER_FLAG_CLAMP", FILTER_FLAG_CLAMP);
7150 CONSTANT("SWFFILTER_FLAG_PRESERVE_ALPHA", FILTER_FLAG_PRESERVE_ALPHA);
7151
7152 /* filter modes */
7153 CONSTANT("SWFFILTER_MODE_INNER", FILTER_MODE_INNER);
7154 CONSTANT("SWFFILTER_MODE_KO", FILTER_MODE_KO);
7155 CONSTANT("SWFFILTER_MODE_COMPOSITE", FILTER_MODE_COMPOSITE);
7156 CONSTANT("SWFFILTER_MODE_ONTOP", FILTER_MODE_ONTOP);
7157
7158 /* new gradient features */
7159 CONSTANT("SWF_GRADIENT_PAD", SWF_GRADIENT_PAD);
7160 CONSTANT("SWF_GRADIENT_REFLECT", SWF_GRADIENT_REFLECT);
7161 CONSTANT("SWF_GRADIENT_REPEAT", SWF_GRADIENT_REPEAT);
7162 CONSTANT("SWF_GRADIENT_NORMAL", SWF_GRADIENT_NORMAL);
7163 CONSTANT("SWF_GRADIENT_LINEAR", SWF_GRADIENT_LINEAR);
7164
7165 /* shape options */
7166 CONSTANT("SWF_SHAPE3", SWF_SHAPE3);
7167 CONSTANT("SWF_SHAPE4", SWF_SHAPE4);
7168 CONSTANT("SWF_SHAPE_USESCALINGSTROKES", SWF_SHAPE_USESCALINGSTROKES);
7169 CONSTANT("SWF_SHAPE_USENONSCALINGSTROKES", SWF_SHAPE_USENONSCALINGSTROKES);
7170
7171 /* linestyle 2 flags */
7172 CONSTANT("SWF_LINESTYLE_CAP_ROUND", SWF_LINESTYLE_CAP_ROUND);
7173 CONSTANT("SWF_LINESTYLE_CAP_NONE", SWF_LINESTYLE_CAP_NONE);
7174 CONSTANT("SWF_LINESTYLE_CAP_SQUARE", SWF_LINESTYLE_CAP_SQUARE);
7175 CONSTANT("SWF_LINESTYLE_JOIN_ROUND", SWF_LINESTYLE_JOIN_ROUND);
7176 CONSTANT("SWF_LINESTYLE_JOIN_BEVEL", SWF_LINESTYLE_JOIN_BEVEL);
7177 CONSTANT("SWF_LINESTYLE_JOIN_MITER", SWF_LINESTYLE_JOIN_MITER);
7178 CONSTANT("SWF_LINESTYLE_FLAG_NOHSCALE", SWF_LINESTYLE_FLAG_NOHSCALE);
7179 CONSTANT("SWF_LINESTYLE_FLAG_NOVSCALE", SWF_LINESTYLE_FLAG_NOVSCALE);
7180 CONSTANT("SWF_LINESTYLE_FLAG_HINTING", SWF_LINESTYLE_FLAG_HINTING);
7181 CONSTANT("SWF_LINESTYLE_FLAG_NOCLOSE", SWF_LINESTYLE_FLAG_NOCLOSE);
7182 CONSTANT("SWF_LINESTYLE_FLAG_ENDCAP_ROUND", SWF_LINESTYLE_FLAG_ENDCAP_ROUND);
7183 CONSTANT("SWF_LINESTYLE_FLAG_ENDCAP_NONE", SWF_LINESTYLE_FLAG_ENDCAP_NONE);
7184 CONSTANT("SWF_LINESTYLE_FLAG_ENDCAP_SQUARE", SWF_LINESTYLE_FLAG_ENDCAP_SQUARE);
7185
7186 /* flags for SWFVideo */
7187 CONSTANT("SWF_VIDEOSTREAM_MODE_MANUAL", SWFVIDEOSTREAM_MODE_MANUAL);
7188 CONSTANT("SWF_VIDEOSTREAM_MODE_AUTO", SWFVIDEOSTREAM_MODE_AUTO);
7189 #endif
7190
7191 le_swfshapep = zend_register_list_destructors_ex(destroy_SWFShape_resource, NULL, "SWFShape", module_number);
7192 le_swffillp = zend_register_list_destructors_ex(destroy_SWFFill_resource, NULL, "SWFFill", module_number);
7193 le_swfgradientp = zend_register_list_destructors_ex(destroy_SWFGradient_resource, NULL, "SWFGradient", module_number);
7194 le_swfbitmapp = zend_register_list_destructors_ex(destroy_SWFBitmap_resource, NULL, "SWFBitmap", module_number);
7195 le_swftextp = zend_register_list_destructors_ex(destroy_SWFText_resource, NULL, "SWFText", module_number);
7196 le_swftextfieldp = zend_register_list_destructors_ex(destroy_SWFTextField_resource, NULL, "SWFTextField", module_number);
7197 le_swffontp = zend_register_list_destructors_ex(destroy_SWFFont_resource, NULL, "SWFFont", module_number);
7198 le_swfdisplayitemp = zend_register_list_destructors_ex(NULL, NULL, "SWFDisplayItem", module_number);
7199 le_swfmoviep = zend_register_list_destructors_ex(destroy_SWFMovie_resource, NULL, "SWFMovie", module_number);
7200 le_swfbuttonp = zend_register_list_destructors_ex(destroy_SWFButton_resource, NULL, "SWFButton", module_number);
7201 le_swfactionp = zend_register_list_destructors_ex(NULL, NULL, "SWFAction", module_number);
7202 le_swfmorphp = zend_register_list_destructors_ex(destroy_SWFMorph_resource, NULL, "SWFMorph", module_number);
7203 le_swfmovieclipp = zend_register_list_destructors_ex(destroy_SWFSprite_resource, NULL, "SWFMovieClip", module_number);
7204 le_swfspritep = zend_register_list_destructors_ex(destroy_SWFSprite_resource, NULL, "SWFSprite", module_number);
7205 le_swfinputp = zend_register_list_destructors_ex(destroy_SWFInput_resource, NULL, "SWFInput", module_number);
7206
7207 le_swfsoundp = zend_register_list_destructors_ex(destroy_SWFSound_resource, NULL, "SWFSound", module_number);
7208 #ifdef HAVE_NEW_MING
7209 le_swffontcharp = zend_register_list_destructors_ex(NULL, NULL, "SWFFontCharacter", module_number);
7210 le_swfbuttonrecordp = zend_register_list_destructors_ex(NULL, NULL, "SWFButtonRecord", module_number);
7211 le_swfsoundinstancep = zend_register_list_destructors_ex(NULL, NULL, "SWFSoundInstance", module_number);
7212 le_swfvideostreamp = zend_register_list_destructors_ex(destroy_SWFVideoStream_resource, NULL, "SWFVideoStream", module_number);
7213 le_swfbinarydatap = zend_register_list_destructors_ex(destroy_SWFBinaryData_resource, NULL, "SWFBinaryData", module_number);
7214 le_swfinitactionp = zend_register_list_destructors_ex(NULL, NULL, "SWFInitAction", module_number);
7215 le_swfprebuiltclipp = zend_register_list_destructors_ex(destroy_SWFPrebuiltClip_resource, NULL, "SWFPrebuiltClip", module_number);
7216 le_swfsoundstreamp = zend_register_list_destructors_ex(destroy_SWFSoundStream_resource, NULL, "SWFSoundStream", module_number);
7217 le_swffilterp = zend_register_list_destructors_ex(destroy_SWFFilter_resource, NULL, "SWFFilter", module_number);
7218 le_swfblurp = zend_register_list_destructors_ex(destroy_SWFBlur_resource, NULL, "SWFBlur", module_number);
7219 le_swfshadowp = zend_register_list_destructors_ex(destroy_SWFShadow_resource, NULL, "SWFShadow", module_number);
7220 le_swffiltermatrixp = zend_register_list_destructors_ex(destroy_SWFFilterMatrix_resource, NULL, "SWFFilterMatrix", module_number);
7221 le_swfcharacterp = zend_register_list_destructors_ex(NULL, NULL, "SWFCharacter", module_number);
7222 le_swfcxformp = zend_register_list_destructors_ex(destroy_SWFCXform_resource, NULL, "SWFCXform", module_number);
7223 le_swfmatrixp = zend_register_list_destructors_ex(NULL, NULL, "SWFMatrix", module_number);
7224 le_swfbrowserfontp = zend_register_list_destructors_ex(destroy_SWFBrowserFont_resource, NULL, "SWFBrowserFont", module_number);
7225 le_swffontcollectionp = zend_register_list_destructors_ex(destroy_SWFFontCollection_resource, NULL, "SWFFontCollection", module_number);
7226 #endif
7227
7228 INIT_CLASS_ENTRY(shape_class_entry, "SWFShape", swfshape_functions);
7229 INIT_CLASS_ENTRY(fill_class_entry, "SWFFill", swffill_functions);
7230 INIT_CLASS_ENTRY(gradient_class_entry, "SWFGradient", swfgradient_functions);
7231 INIT_CLASS_ENTRY(bitmap_class_entry, "SWFBitmap", swfbitmap_functions);
7232 INIT_CLASS_ENTRY(text_class_entry, "SWFText", swftext_functions);
7233 INIT_CLASS_ENTRY(textfield_class_entry, "SWFTextField", swftextfield_functions);
7234 INIT_CLASS_ENTRY(font_class_entry, "SWFFont", swffont_functions);
7235 INIT_CLASS_ENTRY(displayitem_class_entry, "SWFDisplayItem", swfdisplayitem_functions);
7236 INIT_CLASS_ENTRY(movie_class_entry, "SWFMovie", swfmovie_functions);
7237 INIT_CLASS_ENTRY(button_class_entry, "SWFButton", swfbutton_functions);
7238 INIT_CLASS_ENTRY(action_class_entry, "SWFAction", swfaction_functions);
7239 INIT_CLASS_ENTRY(morph_class_entry, "SWFMorph", swfmorph_functions);
7240 INIT_CLASS_ENTRY(movieclip_class_entry, "SWFMovieClip", swfmovieclip_functions);
7241 INIT_CLASS_ENTRY(sprite_class_entry, "SWFSprite", swfsprite_functions);
7242 INIT_CLASS_ENTRY(sound_class_entry, "SWFSound", swfsound_functions);
7243 #ifdef HAVE_NEW_MING
7244 INIT_CLASS_ENTRY(fontchar_class_entry, "SWFFontChar", swffontchar_functions);
7245 INIT_CLASS_ENTRY(buttonrecord_class_entry, "SWFButtonRecord", swfbuttonrecord_functions);
7246 INIT_CLASS_ENTRY(soundinstance_class_entry, "SWFSoundInstance", swfsoundinstance_functions);
7247 INIT_CLASS_ENTRY(videostream_class_entry, "SWFVideoStream", swfvideostream_functions);
7248 INIT_CLASS_ENTRY(binarydata_class_entry, "SWFBinaryData", swfbinarydata_functions);
7249 INIT_CLASS_ENTRY(initaction_class_entry, "SWFInitAction", swfinitaction_functions);
7250 INIT_CLASS_ENTRY(prebuiltclip_class_entry, "SWFPrebuiltClip", swfprebuiltclip_functions);
7251 INIT_CLASS_ENTRY(soundstream_class_entry, "SWFSoundStream", swfsoundstream_functions);
7252 INIT_CLASS_ENTRY(filter_class_entry, "SWFFilter", swffilter_functions);
7253 INIT_CLASS_ENTRY(filtermatrix_class_entry, "SWFFilterMatrix", swffiltermatrix_functions);
7254 INIT_CLASS_ENTRY(shadow_class_entry, "SWFShadow", swfshadow_functions);
7255 INIT_CLASS_ENTRY(blur_class_entry, "SWFBlur", swfblur_functions);
7256 INIT_CLASS_ENTRY(cxform_class_entry, "SWFCXform", swfcxform_functions);
7257 INIT_CLASS_ENTRY(matrix_class_entry, "SWFMatrix", swfmatrix_functions);
7258 INIT_CLASS_ENTRY(input_class_entry, "SWFInput", swfinput_functions);
7259 INIT_CLASS_ENTRY(browserfont_class_entry, "SWFBrowserFont", swfbrowserfont_functions);
7260 INIT_CLASS_ENTRY(fontcollection_class_entry, "SWFFontCollection", swffontcollection_functions);
7261 #endif
7262 INIT_CLASS_ENTRY(character_class_entry, "SWFCharacter", swfcharacter_functions);
7263
7264
7265 shape_class_entry_ptr = zend_register_internal_class(&shape_class_entry TSRMLS_CC);
7266 fill_class_entry_ptr = zend_register_internal_class(&fill_class_entry TSRMLS_CC);
7267 gradient_class_entry_ptr = zend_register_internal_class(&gradient_class_entry TSRMLS_CC);
7268 bitmap_class_entry_ptr = zend_register_internal_class(&bitmap_class_entry TSRMLS_CC);
7269 text_class_entry_ptr = zend_register_internal_class(&text_class_entry TSRMLS_CC);
7270 textfield_class_entry_ptr = zend_register_internal_class(&textfield_class_entry TSRMLS_CC);
7271 font_class_entry_ptr = zend_register_internal_class(&font_class_entry TSRMLS_CC);
7272 displayitem_class_entry_ptr = zend_register_internal_class(&displayitem_class_entry TSRMLS_CC);
7273 movie_class_entry_ptr = zend_register_internal_class(&movie_class_entry TSRMLS_CC);
7274 button_class_entry_ptr = zend_register_internal_class(&button_class_entry TSRMLS_CC);
7275 action_class_entry_ptr = zend_register_internal_class(&action_class_entry TSRMLS_CC);
7276 morph_class_entry_ptr = zend_register_internal_class(&morph_class_entry TSRMLS_CC);
7277 movieclip_class_entry_ptr = zend_register_internal_class(&movieclip_class_entry TSRMLS_CC);
7278 sprite_class_entry_ptr = zend_register_internal_class(&sprite_class_entry TSRMLS_CC);
7279 sound_class_entry_ptr = zend_register_internal_class(&sound_class_entry TSRMLS_CC);
7280 #ifdef HAVE_NEW_MING
7281 fontchar_class_entry_ptr = zend_register_internal_class(&fontchar_class_entry TSRMLS_CC);
7282 buttonrecord_class_entry_ptr = zend_register_internal_class(&buttonrecord_class_entry TSRMLS_CC);
7283 soundinstance_class_entry_ptr = zend_register_internal_class(&soundinstance_class_entry TSRMLS_CC);
7284 videostream_class_entry_ptr = zend_register_internal_class(&videostream_class_entry TSRMLS_CC);
7285 binarydata_class_entry_ptr = zend_register_internal_class(&binarydata_class_entry TSRMLS_CC);
7286 initaction_class_entry_ptr = zend_register_internal_class(&initaction_class_entry TSRMLS_CC);
7287 prebuiltclip_class_entry_ptr = zend_register_internal_class(&prebuiltclip_class_entry TSRMLS_CC);
7288 soundstream_class_entry_ptr = zend_register_internal_class(&soundstream_class_entry TSRMLS_CC);
7289 filter_class_entry_ptr = zend_register_internal_class(&filter_class_entry TSRMLS_CC);
7290 filtermatrix_class_entry_ptr = zend_register_internal_class(&filtermatrix_class_entry TSRMLS_CC);
7291 shadow_class_entry_ptr = zend_register_internal_class(&shadow_class_entry TSRMLS_CC);
7292 blur_class_entry_ptr = zend_register_internal_class(&blur_class_entry TSRMLS_CC);
7293 cxform_class_entry_ptr = zend_register_internal_class(&cxform_class_entry TSRMLS_CC);
7294 matrix_class_entry_ptr = zend_register_internal_class(&matrix_class_entry TSRMLS_CC);
7295 input_class_entry_ptr = zend_register_internal_class(&input_class_entry TSRMLS_CC);
7296 browserfont_class_entry_ptr = zend_register_internal_class(&browserfont_class_entry TSRMLS_CC);
7297 fontcollection_class_entry_ptr = zend_register_internal_class(&fontcollection_class_entry TSRMLS_CC);
7298 #endif
7299 character_class_entry_ptr = zend_register_internal_class(&character_class_entry TSRMLS_CC);
7300 return SUCCESS;
7301 }
7302 /* }}} */
7303
7304 #endif
7305
7306 /*
7307 * Local variables:
7308 * tab-width: 4
7309 * c-basic-offset: 4
7310 * End:
7311 * vim600: sw=4 ts=4 fdm=marker
7312 * vim<600: sw=4 ts=4
7313 */
7314