1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

several fixes to com_dotnet for x64

This commit is contained in:
Anatol Belski
2014-10-28 16:37:04 +01:00
parent 3b6a9a3916
commit 26e7e54e78
4 changed files with 670 additions and 3 deletions

View File

@@ -454,6 +454,10 @@ PHP_MINIT_FUNCTION(com_dotnet)
COM_ERR_CONST(DISP_E_BADINDEX);
COM_ERR_CONST(MK_E_UNAVAILABLE);
#if SIZEOF_ZEND_LONG == 8
COM_CONST(VT_UI8);
COM_CONST(VT_I8);
#endif
return SUCCESS;
}
/* }}} */

View File

@@ -204,11 +204,19 @@ PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepa
ZVAL_LONG(z, (zend_long)V_I2(v));
break;
case VT_UI4: /* TODO: promote to double if large? */
ZVAL_LONG(z, (zend_long)V_UI4(v));
ZVAL_LONG(z, (long)V_UI4(v));
break;
case VT_I4:
ZVAL_LONG(z, (zend_long)V_I4(v));
ZVAL_LONG(z, (long)V_I4(v));
break;
#if SIZEOF_ZEND_LONG == 8
case VT_UI8:
ZVAL_LONG(z, (zend_long)V_UI8(v));
break;
case VT_I8:
ZVAL_LONG(z, (zend_long)V_I8(v));
break;
#endif
case VT_INT:
ZVAL_LONG(z, V_INT(v));
break;
@@ -333,7 +341,23 @@ PHP_COM_DOTNET_API int php_com_copy_variant(VARIANT *dstvar, VARIANT *srcvar TSR
V_I4(dstvar) = V_I4(srcvar);
}
break;
#if SIZEOF_ZEND_LONG == 8
case VT_UI8:
if (V_VT(dstvar) & VT_BYREF) {
*V_UI8REF(dstvar) = V_UI8(srcvar);
} else {
V_UI8(dstvar) = V_UI8(srcvar);
}
break;
case VT_I8:
if (V_VT(dstvar) & VT_BYREF) {
*V_I8REF(dstvar) = V_I8(srcvar);
} else {
V_I8(dstvar) = V_I8(srcvar);
}
break;
#endif
case VT_INT:
if (V_VT(dstvar) & VT_BYREF) {
*V_INTREF(dstvar) = V_INT(srcvar);

View File

@@ -2,7 +2,8 @@
COM: General variant tests
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present";
if (4 != PHP_INT_SIZE) print "skip x86 only"; ?>
--FILE--
<?php // $Id$
error_reporting(E_ALL);

View File

@@ -0,0 +1,638 @@
--TEST--
COM: General variant tests
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present";
if (8 != PHP_INT_SIZE) print "skip x64 only"; ?>
--FILE--
<?php // $Id$
error_reporting(E_ALL);
$v = new VARIANT();
if (VT_EMPTY != variant_get_type($v)) {
echo "VT_EMPTY: bork\n";
}
$values = array(VT_I8 => 42, VT_R8 => 3.5, VT_BSTR => "hello", VT_BOOL => false);
$binary_ops = array('add', 'cat', 'sub', 'mul', 'and', 'div',
'eqv', 'idiv', 'imp', 'mod', 'or', 'pow', 'xor');
foreach ($values as $t => $val) {
$v = new VARIANT($val);
if ($t != variant_get_type($v)) {
printf("Bork: [%d] %d: %s\n", $t, variant_get_type($v), $val);
print $v . "\n";
}
$results = array();
foreach ($values as $op2) {
echo "--\n";
foreach ($binary_ops as $op) {
try {
echo "$op: " . call_user_func('variant_' . $op, $v, $op2) . "\n";
} catch (com_exception $e) {
echo "$op:\n";
echo "\tvariant_$op($v, $op2)\n";
echo "\texception " . $e->getMessage();
printf("\tcode %08x\n\n", $e->getCode());
}
}
}
}
echo "OK!";
?>
--EXPECT--
--
add: 84
cat: 4242
sub: 0
mul: 1764
and: 42
div: 1
eqv: -1
idiv: 1
imp: -1
mod: 0
or: 42
pow: 1.50130937545297E+68
xor: 0
--
add: 45.5
cat: 423.5
sub: 38.5
mul: 147
and: 0
div: 12
eqv: -47
idiv: 10
imp: -43
mod: 2
or: 46
pow: 480145.116863642
xor: 46
--
add:
variant_add(42, hello)
exception Type mismatch.
code 80020005
cat: 42hello
sub:
variant_sub(42, hello)
exception Type mismatch.
code 80020005
mul:
variant_mul(42, hello)
exception Type mismatch.
code 80020005
and:
variant_and(42, hello)
exception Type mismatch.
code 80020005
div:
variant_div(42, hello)
exception Type mismatch.
code 80020005
eqv:
variant_eqv(42, hello)
exception Type mismatch.
code 80020005
idiv:
variant_idiv(42, hello)
exception Type mismatch.
code 80020005
imp:
variant_imp(42, hello)
exception Type mismatch.
code 80020005
mod:
variant_mod(42, hello)
exception Type mismatch.
code 80020005
or:
variant_or(42, hello)
exception Type mismatch.
code 80020005
pow:
variant_pow(42, hello)
exception Type mismatch.
code 80020005
xor:
variant_xor(42, hello)
exception Type mismatch.
code 80020005
--
add: 42
cat: 42False
sub: 42
mul: 0
and: 0
div:
variant_div(42, )
exception Division by zero.
code 80020012
eqv: -43
idiv:
variant_idiv(42, )
exception Division by zero.
code 80020012
imp: -43
mod:
variant_mod(42, )
exception Division by zero.
code 80020012
or: 42
pow: 1
xor: 42
--
add: 45.5
cat: 3.542
sub: -38.5
mul: 147
and: 0
div: 8.33333333333333E-02
eqv: -47
idiv: 0
imp: -5
mod: 4
or: 46
pow: 7.09345573078604E+22
xor: 46
--
add: 7
cat: 3.53.5
sub: 0
mul: 12.25
and: 4
div: 1
eqv: -1
idiv: 1
imp: -1
mod: 0
or: 4
pow: 80.2117802289664
xor: 0
--
add:
variant_add(3.5, hello)
exception Type mismatch.
code 80020005
cat: 3.5hello
sub:
variant_sub(3.5, hello)
exception Type mismatch.
code 80020005
mul:
variant_mul(3.5, hello)
exception Type mismatch.
code 80020005
and:
variant_and(3.5, hello)
exception Type mismatch.
code 80020005
div:
variant_div(3.5, hello)
exception Type mismatch.
code 80020005
eqv:
variant_eqv(3.5, hello)
exception Type mismatch.
code 80020005
idiv:
variant_idiv(3.5, hello)
exception Type mismatch.
code 80020005
imp:
variant_imp(3.5, hello)
exception Type mismatch.
code 80020005
mod:
variant_mod(3.5, hello)
exception Type mismatch.
code 80020005
or:
variant_or(3.5, hello)
exception Type mismatch.
code 80020005
pow:
variant_pow(3.5, hello)
exception Type mismatch.
code 80020005
xor:
variant_xor(3.5, hello)
exception Type mismatch.
code 80020005
--
add: 3.5
cat: 3.5False
sub: 3.5
mul: 0
and: 0
div:
variant_div(3.5, )
exception Division by zero.
code 80020012
eqv: -5
idiv:
variant_idiv(3.5, )
exception Division by zero.
code 80020012
imp: -5
mod:
variant_mod(3.5, )
exception Division by zero.
code 80020012
or: 4
pow: 1
xor: 4
--
add:
variant_add(hello, 42)
exception Type mismatch.
code 80020005
cat: hello42
sub:
variant_sub(hello, 42)
exception Type mismatch.
code 80020005
mul:
variant_mul(hello, 42)
exception Type mismatch.
code 80020005
and:
variant_and(hello, 42)
exception Type mismatch.
code 80020005
div:
variant_div(hello, 42)
exception Type mismatch.
code 80020005
eqv:
variant_eqv(hello, 42)
exception Type mismatch.
code 80020005
idiv:
variant_idiv(hello, 42)
exception Type mismatch.
code 80020005
imp:
variant_imp(hello, 42)
exception Type mismatch.
code 80020005
mod:
variant_mod(hello, 42)
exception Type mismatch.
code 80020005
or:
variant_or(hello, 42)
exception Type mismatch.
code 80020005
pow:
variant_pow(hello, 42)
exception Type mismatch.
code 80020005
xor:
variant_xor(hello, 42)
exception Type mismatch.
code 80020005
--
add:
variant_add(hello, 3.5)
exception Type mismatch.
code 80020005
cat: hello3.5
sub:
variant_sub(hello, 3.5)
exception Type mismatch.
code 80020005
mul:
variant_mul(hello, 3.5)
exception Type mismatch.
code 80020005
and:
variant_and(hello, 3.5)
exception Type mismatch.
code 80020005
div:
variant_div(hello, 3.5)
exception Type mismatch.
code 80020005
eqv:
variant_eqv(hello, 3.5)
exception Type mismatch.
code 80020005
idiv:
variant_idiv(hello, 3.5)
exception Type mismatch.
code 80020005
imp:
variant_imp(hello, 3.5)
exception Type mismatch.
code 80020005
mod:
variant_mod(hello, 3.5)
exception Type mismatch.
code 80020005
or:
variant_or(hello, 3.5)
exception Type mismatch.
code 80020005
pow:
variant_pow(hello, 3.5)
exception Type mismatch.
code 80020005
xor:
variant_xor(hello, 3.5)
exception Type mismatch.
code 80020005
--
add: hellohello
cat: hellohello
sub:
variant_sub(hello, hello)
exception Type mismatch.
code 80020005
mul:
variant_mul(hello, hello)
exception Type mismatch.
code 80020005
and:
variant_and(hello, hello)
exception Type mismatch.
code 80020005
div:
variant_div(hello, hello)
exception Type mismatch.
code 80020005
eqv:
variant_eqv(hello, hello)
exception Type mismatch.
code 80020005
idiv:
variant_idiv(hello, hello)
exception Type mismatch.
code 80020005
imp:
variant_imp(hello, hello)
exception Type mismatch.
code 80020005
mod:
variant_mod(hello, hello)
exception Type mismatch.
code 80020005
or:
variant_or(hello, hello)
exception Type mismatch.
code 80020005
pow:
variant_pow(hello, hello)
exception Type mismatch.
code 80020005
xor:
variant_xor(hello, hello)
exception Type mismatch.
code 80020005
--
add:
variant_add(hello, )
exception Type mismatch.
code 80020005
cat: helloFalse
sub:
variant_sub(hello, )
exception Type mismatch.
code 80020005
mul:
variant_mul(hello, )
exception Type mismatch.
code 80020005
and:
variant_and(hello, )
exception Type mismatch.
code 80020005
div:
variant_div(hello, )
exception Type mismatch.
code 80020005
eqv:
variant_eqv(hello, )
exception Type mismatch.
code 80020005
idiv:
variant_idiv(hello, )
exception Type mismatch.
code 80020005
imp:
variant_imp(hello, )
exception Type mismatch.
code 80020005
mod:
variant_mod(hello, )
exception Type mismatch.
code 80020005
or:
variant_or(hello, )
exception Type mismatch.
code 80020005
pow:
variant_pow(hello, )
exception Type mismatch.
code 80020005
xor:
variant_xor(hello, )
exception Type mismatch.
code 80020005
--
add: 42
cat: False42
sub: -42
mul: 0
and: 0
div: 0
eqv: -43
idiv: 0
imp: -1
mod: 0
or: 42
pow: 0
xor: 42
--
add: 3.5
cat: False3.5
sub: -3.5
mul: 0
and: 0
div: 0
eqv: -5
idiv: 0
imp: -1
mod: 0
or: 4
pow: 0
xor: 4
--
add:
variant_add(0, hello)
exception Type mismatch.
code 80020005
cat: Falsehello
sub:
variant_sub(0, hello)
exception Type mismatch.
code 80020005
mul:
variant_mul(0, hello)
exception Type mismatch.
code 80020005
and:
variant_and(0, hello)
exception Type mismatch.
code 80020005
div:
variant_div(0, hello)
exception Type mismatch.
code 80020005
eqv:
variant_eqv(0, hello)
exception Type mismatch.
code 80020005
idiv:
variant_idiv(0, hello)
exception Type mismatch.
code 80020005
imp:
variant_imp(0, hello)
exception Type mismatch.
code 80020005
mod:
variant_mod(0, hello)
exception Type mismatch.
code 80020005
or:
variant_or(0, hello)
exception Type mismatch.
code 80020005
pow:
variant_pow(0, hello)
exception Type mismatch.
code 80020005
xor:
variant_xor(0, hello)
exception Type mismatch.
code 80020005
--
add: 0
cat: FalseFalse
sub: 0
mul: 0
and: 0
div:
variant_div(0, )
exception Out of present range.
code 8002000a
eqv: -1
idiv:
variant_idiv(0, )
exception Division by zero.
code 80020012
imp: -1
mod:
variant_mod(0, )
exception Division by zero.
code 80020012
or: 0
pow: 1
xor: 0
OK!