rrichards               Sun Dec 24 10:02:00 2006 UTC

  Modified files:              
    /php-src/ext/com_dotnet     com_handlers.c com_variant.c com_wrapper.c 
    /php-src/ext/com_dotnet/tests       bug33386.phpt bug39596.phpt 
  Log:
  MFB:
  - fix bug #33386 (ScriptControl only sees last function of class): 
com_wrapper.c
  - fix bug #37588 (COM Property propputref converts to PHP function 
    and can't be accesed): com_handlers.c
  - fix bug #39596 (Creating Variant of type VT_ARRAY): com_variant.c
  - add tests
  
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_handlers.c?r1=1.40&r2=1.41&diff_format=u
Index: php-src/ext/com_dotnet/com_handlers.c
diff -u php-src/ext/com_dotnet/com_handlers.c:1.40 
php-src/ext/com_dotnet/com_handlers.c:1.41
--- php-src/ext/com_dotnet/com_handlers.c:1.40  Fri Nov 17 11:41:13 2006
+++ php-src/ext/com_dotnet/com_handlers.c       Sun Dec 24 10:02:00 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_handlers.c,v 1.40 2006/11/17 11:41:13 dmitry Exp $ */
+/* $Id: com_handlers.c,v 1.41 2006/12/24 10:02:00 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -76,7 +76,7 @@
 
                convert_to_string_ex(&member);
                if (SUCCESS == php_com_do_invoke(obj, Z_STRVAL_P(member), 
Z_STRLEN_P(member),
-                               DISPATCH_PROPERTYPUT, &v, 1, &value TSRMLS_CC)) 
{
+                               DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF, 
&v, 1, &value TSRMLS_CC)) {
                        VariantClear(&v);
                }
        } else {
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_variant.c?r1=1.18&r2=1.19&diff_format=u
Index: php-src/ext/com_dotnet/com_variant.c
diff -u php-src/ext/com_dotnet/com_variant.c:1.18 
php-src/ext/com_dotnet/com_variant.c:1.19
--- php-src/ext/com_dotnet/com_variant.c:1.18   Fri Nov 17 11:41:13 2006
+++ php-src/ext/com_dotnet/com_variant.c        Sun Dec 24 10:02:00 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_variant.c,v 1.18 2006/11/17 11:41:13 dmitry Exp $ */
+/* $Id: com_variant.c,v 1.19 2006/12/24 10:02:00 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -296,19 +296,36 @@
                php_com_variant_from_zval(&obj->v, zvalue, obj->code_page 
TSRMLS_CC);
        }
 
-       if (ZEND_NUM_ARGS() >= 2) {
+       /* Only perform conversion if variant not already of type passed */
+       if ((ZEND_NUM_ARGS() >= 2) && (vt != V_VT(&obj->v))) {
 
-               res = VariantChangeType(&obj->v, &obj->v, 0, (VARTYPE)vt);
+               /* If already an array and VT_ARRAY is passed then:
+                       - if only VT_ARRAY passed then do not perform a 
conversion
+                       - if VT_ARRAY plus other type passed then perform 
conversion 
+                         but will probably fail (origional behavior)
+               */
+               if ((vt & VT_ARRAY) && (V_VT(&obj->v) & VT_ARRAY)) {
+                       long orig_vt = vt;
+
+                       vt &= ~VT_ARRAY;
+                       if (vt) {
+                               vt = orig_vt;
+                       }
+               }
 
-               if (FAILED(res)) {
-                       char *werr, *msg;
+               if (vt) {
+                       res = VariantChangeType(&obj->v, &obj->v, 0, 
(VARTYPE)vt);
 
-                       werr = php_win_err(res);
-                       spprintf(&msg, 0, "Variant type conversion failed: %s", 
werr);
-                       LocalFree(werr);
+                       if (FAILED(res)) {
+                               char *werr, *msg;
 
-                       php_com_throw_exception(res, msg TSRMLS_CC);
-                       efree(msg);
+                               werr = php_win_err(res);
+                               spprintf(&msg, 0, "Variant type conversion 
failed: %s", werr);
+                               LocalFree(werr);
+
+                               php_com_throw_exception(res, msg TSRMLS_CC);
+                               efree(msg);
+                       }
                }
        }
 
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_wrapper.c?r1=1.10&r2=1.11&diff_format=u
Index: php-src/ext/com_dotnet/com_wrapper.c
diff -u php-src/ext/com_dotnet/com_wrapper.c:1.10 
php-src/ext/com_dotnet/com_wrapper.c:1.11
--- php-src/ext/com_dotnet/com_wrapper.c:1.10   Sun Jan  1 13:09:48 2006
+++ php-src/ext/com_dotnet/com_wrapper.c        Sun Dec 24 10:02:00 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_wrapper.c,v 1.10 2006/01/01 13:09:48 sniper Exp $ */
+/* $Id: com_wrapper.c,v 1.11 2006/12/24 10:02:00 rrichards Exp $ */
 
 /* This module exports a PHP object as a COM object by wrapping it
  * using IDispatchEx */
@@ -477,6 +477,7 @@
                        /* add the mappings */
                        MAKE_STD_ZVAL(tmp);
                        ZVAL_STRINGL(tmp, name, namelen-1, 1);
+                       pid = zend_hash_next_free_element(disp->dispid_to_name);
                        zend_hash_index_update(disp->dispid_to_name, pid, 
(void*)&tmp, sizeof(zval *), NULL);
 
                        MAKE_STD_ZVAL(tmp);
@@ -508,6 +509,7 @@
                        /* add the mappings */
                        MAKE_STD_ZVAL(tmp);
                        ZVAL_STRINGL(tmp, name, namelen-1, 1);
+                       pid = zend_hash_next_free_element(disp->dispid_to_name);
                        zend_hash_index_update(disp->dispid_to_name, pid, 
(void*)&tmp, sizeof(zval *), NULL);
 
                        MAKE_STD_ZVAL(tmp);
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/tests/bug33386.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/com_dotnet/tests/bug33386.phpt
diff -u /dev/null php-src/ext/com_dotnet/tests/bug33386.phpt:1.2
--- /dev/null   Sun Dec 24 10:02:00 2006
+++ php-src/ext/com_dotnet/tests/bug33386.phpt  Sun Dec 24 10:02:00 2006
@@ -0,0 +1,40 @@
+--TEST--
+Bug #33386 (ScriptControl only sees last function of class)
+--SKIPIF--
+<?php 
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not 
present"; ?>
+--FILE--
+<?php 
+error_reporting(E_ALL);
+
+class twoFuncs {
+    public function func1() { echo " func one\n"; }
+    public function func2() { echo " func two\n"; }
+}
+
+try {
+       $ciTF = new twoFuncs;
+
+       $oScript = new COM("MSScriptControl.ScriptControl");
+       $oScript->Language = "VBScript";
+
+       $oScript->AddObject ("tfA", $ciTF, true);
+       foreach (array(1,2) as $i) {
+               $oScript->ExecuteStatement ("tfA.func$i");
+               $oScript->ExecuteStatement ("func$i");
+       }
+       $oScript->AddObject ("tfB", $ciTF);
+       foreach (array(1,2) as $i) {
+               $oScript->ExecuteStatement ("tfB.func$i");
+       }
+} catch (Exception $e) {
+       print $e;
+}
+?>
+--EXPECT--
+ func one
+ func one
+ func two
+ func two
+ func one
+ func two
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/tests/bug39596.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/com_dotnet/tests/bug39596.phpt
diff -u /dev/null php-src/ext/com_dotnet/tests/bug39596.phpt:1.2
--- /dev/null   Sun Dec 24 10:02:00 2006
+++ php-src/ext/com_dotnet/tests/bug39596.phpt  Sun Dec 24 10:02:00 2006
@@ -0,0 +1,23 @@
+--TEST--
+Bug #39596 (Creating Variant of type VT_ARRAY)
+--SKIPIF--
+<?php 
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not 
present"; ?>
+--FILE--
+<?php 
+error_reporting(E_ALL);
+
+try {
+       $binding_string = array('aaa','bbb','ccc');
+       $v = new VARIANT( $binding_string, VT_ARRAY );
+       foreach ($v AS $element) {
+               print $element."\n";
+       }
+} catch (Exception $e) {
+       print $e;
+}
+?>
+--EXPECT--
+aaa
+bbb
+ccc

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to