[PHP-CVS] cvs: php4 /ext/ming ming.c php_ming.h

2001-03-12 Thread Dave Hayden

opaquedave  Mon Mar 12 17:57:39 2001 EDT

  Modified files:  
/php4/ext/ming  ming.c php_ming.h 
  Log:
  changed scalar args and returns to doubles, added Ming_setScale function,
  added SWFTEXTFIELD_HTML flag, fixed SWFTextField_setIndentation glitch
  
  

Index: php4/ext/ming/ming.c
diff -u php4/ext/ming/ming.c:1.2 php4/ext/ming/ming.c:1.3
--- php4/ext/ming/ming.c:1.2Sun Feb 25 22:07:02 2001
+++ php4/ext/ming/ming.cMon Mar 12 17:57:38 2001
@@ -26,8 +26,9 @@
 #include "php_ming.h"
 
 static zend_function_entry ming_functions[] = {
-  PHP_FALIAS(ming_setcubicthreshold,  ming_setCubicThreshold,  NULL)
-  PHP_FALIAS(swfbutton_keypress,  swfbutton_keypress,  NULL)
+  PHP_FALIAS(ming_setcubicthreshold,  ming_setCubicThreshold,  NULL)
+  PHP_FALIAS(ming_setscale,   ming_setScale,   NULL)
+  PHP_FALIAS(swfbutton_keypress,  swfbutton_keypress,  NULL)
   { NULL, NULL, NULL }
 };
 
@@ -35,8 +36,7 @@
 {
   zval **num;
 
-  if(ZEND_NUM_ARGS() != 1 ||
- zend_get_parameters_ex(1, &num) == FAILURE)
+  if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE)
 WRONG_PARAM_COUNT;
 
   convert_to_long_ex(num);
@@ -44,6 +44,18 @@
   Ming_setCubicThreshold(Z_LVAL_PP(num));
 }
 
+PHP_FUNCTION(ming_setScale)
+{
+  zval **num;
+
+  if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE)
+WRONG_PARAM_COUNT;
+
+  convert_to_double_ex(num);
+
+  Ming_setScale(Z_DVAL_PP(num));
+}
+
 static int le_swfmoviep;
 static int le_swfshapep;
 static int le_swffillp;
@@ -141,12 +153,11 @@
 
 static zend_function_entry swfaction_functions[] = {
   PHP_FALIAS(swfaction,  swfaction_init, NULL)
-  PHP_FALIAS(add,swfaction_add,  NULL)
   { NULL, NULL, NULL }
 };
 
-/* {{{ proto object swfaction_init([string])
-   returns a new SWFAction object, optionally compiling the given script */
+/* {{{ proto object swfaction_init(string)
+   returns a new SWFAction object, compiling the given script */
 
 PHP_FUNCTION(swfaction_init)
 {
@@ -154,27 +165,16 @@
   zval **script;
   int ret;
 
-  if(ZEND_NUM_ARGS() == 0)
-  {
-action = newSWFAction();
-  }
-  if(ZEND_NUM_ARGS() == 1)
-  {
-SWFOutput out;
-
-if(zend_get_parameters_ex(1, &script) == FAILURE)
-  WRONG_PARAM_COUNT;
+  if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &script) == FAILURE)
+WRONG_PARAM_COUNT;
 
-convert_to_string_ex(script);
+  convert_to_string_ex(script);
 
-/* XXX - need to deal with compiler errors */
-action = compileSWFActionCode(Z_STRVAL_PP(script));
+  /* XXX - need to deal with compiler errors */
+  action = compileSWFActionCode(Z_STRVAL_PP(script));
 
-if(!action)
-  php_error(E_ERROR, "Couldn't compile code.  And I'm not smart enough to tell 
you why, sorry.");
-  }
-  else
-WRONG_PARAM_COUNT;
+  if(!action)
+php_error(E_ERROR, "Couldn't compile code.  And I'm not smart enough to tell you 
+why, sorry.");
 
   ret = zend_list_insert(action, le_swfactionp);
 
@@ -199,17 +199,7 @@
 }
 
 /* }}} */
-/* {{{ proto void swfaction_add(action, [args..])
-   adds the given action (and optional args) to this SWFAction */
 
-PHP_FUNCTION(swfaction_add)
-{
-  SWFAction action = getAction(getThis());
-  /* XXX - etc. */
-}
-
-/* }}} */
-
 /* }}} */
 /* {{{ SWFBitmap */
 
@@ -324,7 +314,7 @@
   if(ZEND_NUM_ARGS() != 0)
 WRONG_PARAM_COUNT;
 
-  RETURN_LONG(SWFBitmap_getWidth(getBitmap(getThis(;
+  RETURN_DOUBLE(SWFBitmap_getWidth(getBitmap(getThis(;
 }
 
 /* }}} */
@@ -336,7 +326,7 @@
   if(ZEND_NUM_ARGS() != 0)
 WRONG_PARAM_COUNT;
 
-  RETURN_LONG(SWFBitmap_getHeight(getBitmap(getThis(;
+  RETURN_DOUBLE(SWFBitmap_getHeight(getBitmap(getThis(;
 }
 
 /* }}} */
@@ -596,10 +586,10 @@
   if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE)
 WRONG_PARAM_COUNT;
 
-  convert_to_long_ex(x);
-  convert_to_long_ex(y);
+  convert_to_double_ex(x);
+  convert_to_double_ex(y);
 
-  SWFDisplayItem_moveTo(getDisplayItem(getThis()), Z_LVAL_PP(x), Z_LVAL_PP(y));
+  SWFDisplayItem_moveTo(getDisplayItem(getThis()), Z_DVAL_PP(x), Z_DVAL_PP(y));
 }
 
 /* }}} */
@@ -613,10 +603,10 @@
   if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE)
 WRONG_PARAM_COUNT;
 
-  convert_to_long_ex(x);
-  convert_to_long_ex(y);
+  convert_to_double_ex(x);
+  convert_to_double_ex(y);
 
-  SWFDisplayItem_move(getDisplayItem(getThis()), Z_LVAL_PP(x), Z_LVAL_PP(y));
+  SWFDisplayItem_move(getDisplayItem(getThis()), Z_DVAL_PP(x), Z_DVAL_PP(y));
 }
 
 /* }}} */
@@ -968,10 +958,10 @@
   if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE)
 WRONG_PARAM_COUNT;
 
-  convert_to_long_ex(x);
-  convert_to_long_ex(y);
+  convert_to_double_ex(x);
+  convert_to_double_ex(y);
 
-  SWFFill_moveTo(getFill(getThis()), Z_LVAL_PP(x), Z_LVAL_PP(y));
+  SWFFill_moveTo(getFill(getThis()), Z_DVAL_PP(x), Z_DVAL_PP(y));
 }
 
 /* }}} */
@@ -1129,7

[PHP-CVS] cvs: php4 /ext/ming Makefile.in config.m4 ming.c php_ming.h

2001-01-26 Thread Dave Hayden

opaquedave  Fri Jan 26 16:26:23 2001 EDT

  Added files: 
/php4/ext/ming  Makefile.in config.m4 ming.c php_ming.h 
  Log:
  First include of ming (SWF generation) library wrapper
  
http://www.opaque.net/ming/
  
  
  


Index: php4/ext/ming/Makefile.in
+++ php4/ext/ming/Makefile.in
# $Id: Makefile.in,v 1.1 2001/01/27 00:26:22 opaquedave Exp $

LTLIBRARY_NAME= libming.la
LTLIBRARY_SOURCES = ming.c
LTLIBRARY_SHARED_NAME = ming.la
LTLIBRARY_SHARED_LIBADD = $(MING_SHARED_LIBADD)

include $(top_srcdir)/build/dynlib.mk

Index: php4/ext/ming/config.m4
+++ php4/ext/ming/config.m4
dnl $Id: config.m4,v 1.1 2001/01/27 00:26:22 opaquedave Exp $
dnl config.m4 for extension libming
dnl don't forget to call PHP_EXTENSION(ming)
dnl This file is a modified version of config.m4
dnl in php4/ext/mcrypt

PHP_ARG_WITH(ming, for ming support,
[  --with-ming[=DIR]Include ming support])

if test "$withval" != "no"; then
  for i in /usr/lib /usr/local /usr $withval; do
if test -r $i/libming.so; then
  MING_DIR=$i
fi
  done

  if test -z "$MING_DIR"; then
AC_MSG_ERROR(Please reinstall libming.so - I cannot find libming.so)
  fi

  AC_ADD_INCLUDE($MING_DIR)

  PHP_SUBST(MING_SHARED_LIBADD)
  AC_ADD_LIBRARY_WITH_PATH(ming, $MING_DIR, MING_SHARED_LIBADD)
  AC_DEFINE(HAVE_MING,1,[ ])

  PHP_EXTENSION(ming, $ext_shared)
fi

Index: php4/ext/ming/ming.c
+++ php4/ext/ming/ming.c
/*
   +--+
   | PHP version 4.0  |
   +--+
   | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group   |
   +--+
   | This source file is subject to version 2.01 of the PHP license,  |
   | that is bundled with this package in the file LICENSE, and is|
   | available at through the world-wide-web at   |
   | http://www.php.net/license/2_01.txt. |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to  |
   | [EMAIL PROTECTED] so we can mail you a copy immediately.   |
   +--+
   | Author: [EMAIL PROTECTED]  |
   +--+
*/

#include 
#include 

#include "php.h"

#if HAVE_MING
#include "ext/standard/info.h"
#include "php_ming.h"

static zend_function_entry ming_functions[] = {
  PHP_FALIAS(ming_setcubicthreshold,  ming_setCubicThreshold,  NULL)
  PHP_FALIAS(swfbutton_keypress,  swfbutton_keypress,  NULL)
  { NULL, NULL, NULL }
};

PHP_FUNCTION(ming_setCubicThreshold)
{
  zval **num;

  if(ZEND_NUM_ARGS() != 1 ||
 zend_get_parameters_ex(1, &num) == FAILURE)
WRONG_PARAM_COUNT;

  convert_to_long_ex(num);

  Ming_setCubicThreshold(Z_LVAL_PP(num));
}

static int le_swfmoviep;
static int le_swfshapep;
static int le_swffillp;
static int le_swfgradientp;
static int le_swfbitmapp;
static int le_swffontp;
static int le_swftextp;
static int le_swftextfieldp;
static int le_swfdisplayitemp;
static int le_swfbuttonp;
static int le_swfactionp;
static int le_swfmorphp;
static int le_swfspritep;

static int le_fopen;

zend_class_entry movie_class_entry;
zend_class_entry shape_class_entry;
zend_class_entry fill_class_entry;
zend_class_entry gradient_class_entry;
zend_class_entry bitmap_class_entry;
zend_class_entry font_class_entry;
zend_class_entry text_class_entry;
zend_class_entry textfield_class_entry;
zend_class_entry displayitem_class_entry;
zend_class_entry button_class_entry;
zend_class_entry action_class_entry;
zend_class_entry morph_class_entry;
zend_class_entry sprite_class_entry;

/* {{{ internal function SWFgetProperty
 */

static void *SWFgetProperty(zval *id, char *name, int namelen, int proptype)
{
  zval **tmp;
  int id_to_find;
  void *property;
  int type;

  if(id)
  {
if(zend_hash_find(id->value.obj.properties, name, namelen+1, (void **)&tmp) == 
FAILURE)
{
  php_error(E_WARNING, "unable to find property %s", name);
  return NULL;
}
id_to_find = (*tmp)->value.lval;
  }
  else
return NULL;

  property = zend_list_find(id_to_find, &type);

  if (!property || type != proptype)
  {
php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
return NULL;
  }

  return property;
}

/* }}} */
/* {{{ SWFCharacter - not a real class */

/* {{{ internal function SWFCharacter getCharacter(zval *id)
   Returns the SWFCharacter contained in zval *id */

SWFCharacter getCharacter(zval *id)
{
  if(id->value.obj.ce == &shape_class_entry)
return (SWFCharacter)getShape(id);
  else if(id->value.obj.ce == &font_class_entry)
return