summaryrefslogtreecommitdiff
path: root/ext/com_dotnet
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-11-18 21:18:52 +0100
committerAnatol Belski <ab@php.net>2014-11-18 21:18:52 +0100
commitc6bad96f306df8e8b656472e618283ced5083cdb (patch)
tree7e5b52aa07777f0336b0944a228bf66f8f56b31f /ext/com_dotnet
parent4262663e4caa82ba17666781a95bdcb872b4e109 (diff)
parent64a39dc7b07d4b54d050a3a5c15045fe91c0b651 (diff)
downloadphp-git-c6bad96f306df8e8b656472e618283ced5083cdb.tar.gz
Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: (398 commits) NEWS add test for bug #68381 Fixed bug #68381 Set FPM log level earlier during init proper dllexport move to size_t where zend_string is used internally fix some datatype mismatches return after the warning, to fix uninitialized salt usage fix datatype mismatches add missing type specifier fix datatype mismatches fix unsigned check "extern" shouldn't be used for definitions joined identical conditional blocks simplify fpm tests SEND_VAR_NO_REF optimization Add test for bug #68442 Add various tests for FPM - covering recent bugs (68420, 68421, 68423, 68428) - for UDS - for ping and status URI - for multi pool and multi mode Include small MIT FastCGI client library from https://github.com/adoy/PHP-FastCGI-Client Get rid of zend_free_op structure (use zval* instead). Get rid of useless TSRMLS arguments. Add new FPM test for IPv4/IPv6 ... Conflicts: win32/build/config.w32
Diffstat (limited to 'ext/com_dotnet')
-rw-r--r--ext/com_dotnet/com_com.c77
-rw-r--r--ext/com_dotnet/com_extension.c6
-rw-r--r--ext/com_dotnet/com_handlers.c4
-rw-r--r--ext/com_dotnet/com_misc.c4
-rw-r--r--ext/com_dotnet/com_olechar.c2
-rw-r--r--ext/com_dotnet/com_persist.c10
-rw-r--r--ext/com_dotnet/com_saproxy.c10
-rw-r--r--ext/com_dotnet/com_typeinfo.c8
-rw-r--r--ext/com_dotnet/com_variant.c54
-rw-r--r--ext/com_dotnet/com_wrapper.c4
-rw-r--r--ext/com_dotnet/php_com_dotnet_internal.h5
-rw-r--r--ext/com_dotnet/tests/bug33386.phpt4
-rw-r--r--ext/com_dotnet/tests/variants.phpt3
-rw-r--r--ext/com_dotnet/tests/variants_x64.phpt638
14 files changed, 756 insertions, 73 deletions
diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c
index 5f0b8ff697..7de6d949bb 100644
--- a/ext/com_dotnet/com_com.c
+++ b/ext/com_dotnet/com_com.c
@@ -37,7 +37,7 @@ PHP_FUNCTION(com_create_instance)
php_com_dotnet_object *obj;
char *module_name, *typelib_name = NULL, *server_name = NULL;
char *user_name = NULL, *domain_name = NULL, *password = NULL;
- size_t module_name_len, typelib_name_len, server_name_len,
+ size_t module_name_len = 0, typelib_name_len = 0, server_name_len = 0,
user_name_len, domain_name_len, password_len;
OLECHAR *moniker;
CLSID clsid;
@@ -129,11 +129,11 @@ PHP_FUNCTION(com_create_instance)
if (user_name) {
authid.User = php_com_string_to_olestring(user_name, -1, obj->code_page TSRMLS_CC);
- authid.UserLength = user_name_len;
+ authid.UserLength = (ULONG)user_name_len;
if (password) {
authid.Password = (OLECHAR*)password;
- authid.PasswordLength = password_len;
+ authid.PasswordLength = (ULONG)password_len;
} else {
authid.Password = (OLECHAR*)"";
authid.PasswordLength = 0;
@@ -141,7 +141,7 @@ PHP_FUNCTION(com_create_instance)
if (domain_name) {
authid.Domain = (OLECHAR*)domain_name;
- authid.DomainLength = domain_name_len;
+ authid.DomainLength = (ULONG)domain_name_len;
} else {
authid.Domain = (OLECHAR*)"";
authid.DomainLength = 0;
@@ -254,7 +254,7 @@ PHP_FUNCTION(com_create_instance)
ITypeLib_Release(TL);
}
} else if (obj->typeinfo && COMG(autoreg_on)) {
- int idx;
+ UINT idx;
if (SUCCEEDED(ITypeInfo_GetContainingTypeLib(obj->typeinfo, &TL, &idx))) {
/* check if the library is already in the cache by getting its name */
@@ -288,7 +288,7 @@ PHP_FUNCTION(com_get_active_object)
{
CLSID clsid;
char *module_name;
- int module_name_len;
+ size_t module_name_len;
zend_long code_page = COMG(code_page);
IUnknown *unk = NULL;
IDispatch *obj = NULL;
@@ -302,7 +302,7 @@ PHP_FUNCTION(com_get_active_object)
return;
}
- module = php_com_string_to_olestring(module_name, module_name_len, code_page TSRMLS_CC);
+ module = php_com_string_to_olestring(module_name, module_name_len, (int)code_page TSRMLS_CC);
res = CLSIDFromString(module, &clsid);
@@ -320,7 +320,7 @@ PHP_FUNCTION(com_get_active_object)
php_com_throw_exception(res, NULL TSRMLS_CC);
} else if (obj) {
/* we got our dispatchable object */
- php_com_wrap_dispatch(return_value, obj, code_page TSRMLS_CC);
+ php_com_wrap_dispatch(return_value, obj, (int)code_page TSRMLS_CC);
}
}
}
@@ -427,7 +427,7 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
}
if (obj->id_of_name_cache && NULL != (tmp = zend_hash_str_find(obj->id_of_name_cache, name, namelen))) {
- *dispid = Z_LVAL_P(tmp);
+ *dispid = (DISPID)Z_LVAL_P(tmp);
return S_OK;
}
@@ -474,8 +474,8 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *
int i, byref_count = 0, j;
/* assumption: that the active function (f) is the function we generated for the engine */
- if (!f || f->arg_info == NULL) {
- f = NULL;
+ if (!f) {
+ return FAILURE;
}
hr = php_com_get_id_of_name(obj, f->function_name->val, f->function_name->len, &dispid TSRMLS_CC);
@@ -496,7 +496,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *
vargs = (VARIANT*)safe_emalloc(sizeof(VARIANT), nargs, 0);
}
- if (f) {
+ if (f->arg_info) {
for (i = 0; i < nargs; i++) {
if (f->arg_info[nargs - i - 1].pass_by_reference) {
byref_count++;
@@ -551,30 +551,36 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *
/* release variants */
if (vargs) {
- for (i = 0, j = 0; i < nargs; i++) {
- /* if this was byref, update the zval */
- if (f && f->arg_info[nargs - i - 1].pass_by_reference) {
- SEPARATE_ZVAL_IF_NOT_REF(&args[nargs - i - 1]);
-
- /* if the variant is pointing at the byref_vals, we need to map
- * the pointee value as a zval; otherwise, the value is pointing
- * into an existing PHP variant record */
- if (V_VT(&vargs[i]) & VT_BYREF) {
- if (vargs[i].byref == &V_UINT(&byref_vals[j])) {
- /* copy that value */
- php_com_zval_from_variant(&args[nargs - i - 1], &byref_vals[j],
+ if (f && f->arg_info) {
+ for (i = 0, j = 0; i < nargs; i++) {
+ /* if this was byref, update the zval */
+ if (f->arg_info[nargs - i - 1].pass_by_reference) {
+ SEPARATE_ZVAL_IF_NOT_REF(&args[nargs - i - 1]);
+
+ /* if the variant is pointing at the byref_vals, we need to map
+ * the pointee value as a zval; otherwise, the value is pointing
+ * into an existing PHP variant record */
+ if (V_VT(&vargs[i]) & VT_BYREF) {
+ if (vargs[i].byref == &V_UINT(&byref_vals[j])) {
+ /* copy that value */
+ php_com_zval_from_variant(&args[nargs - i - 1], &byref_vals[j],
+ obj->code_page TSRMLS_CC);
+ }
+ } else {
+ /* not sure if this can ever happen; the variant we marked as BYREF
+ * is no longer BYREF - copy its value */
+ php_com_zval_from_variant(&args[nargs - i - 1], &vargs[i],
obj->code_page TSRMLS_CC);
}
- } else {
- /* not sure if this can ever happen; the variant we marked as BYREF
- * is no longer BYREF - copy its value */
- php_com_zval_from_variant(&args[nargs - i - 1], &vargs[i],
- obj->code_page TSRMLS_CC);
+ VariantClear(&byref_vals[j]);
+ j++;
}
- VariantClear(&byref_vals[j]);
- j++;
- }
- VariantClear(&vargs[i]);
+ VariantClear(&vargs[i]);
+ }
+ } else {
+ for (i = 0, j = 0; i < nargs; i++) {
+ VariantClear(&vargs[i]);
+ }
}
efree(vargs);
}
@@ -631,7 +637,7 @@ int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
return SUCCEEDED(hr) ? SUCCESS : FAILURE;
}
-int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
+int php_com_do_invoke(php_com_dotnet_object *obj, char *name, size_t namelen,
WORD flags, VARIANT *v, int nargs, zval *args, int allow_noarg TSRMLS_DC)
{
DISPID dispid;
@@ -687,7 +693,6 @@ PHP_FUNCTION(com_event_sink)
{
zval *object, *sinkobject, *sink=NULL;
char *dispname = NULL, *typelibname = NULL;
- zend_bool gotguid = 0;
php_com_dotnet_object *obj;
ITypeInfo *typeinfo = NULL;
@@ -791,7 +796,7 @@ PHP_FUNCTION(com_message_pump)
RETURN_FALSE;
php_com_initialize(TSRMLS_C);
- result = MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutms, QS_ALLINPUT);
+ result = MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD)timeoutms, QS_ALLINPUT);
if (result == WAIT_OBJECT_0) {
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c
index ce1fa744dd..35fda89963 100644
--- a/ext/com_dotnet/com_extension.c
+++ b/ext/com_dotnet/com_extension.c
@@ -393,7 +393,7 @@ PHP_MINIT_FUNCTION(com_dotnet)
#define COM_ERR_CONST(x) { \
zend_long __tmp; \
- ULongToUIntPtr(x, &__tmp); \
+ ULongToIntPtr(x, &__tmp); \
REGISTER_LONG_CONSTANT(#x, __tmp, CONST_CS|CONST_PERSISTENT); \
}
@@ -460,6 +460,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;
}
/* }}} */
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index 6f63a1fbd8..8b721393fd 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -101,7 +101,7 @@ static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv T
convert_to_long(offset);
if (SafeArrayGetDim(V_ARRAY(&obj->v)) == 1) {
- if (php_com_safearray_get_elem(&obj->v, &v, Z_LVAL_P(offset) TSRMLS_CC)) {
+ if (php_com_safearray_get_elem(&obj->v, &v, (LONG)Z_LVAL_P(offset) TSRMLS_CC)) {
php_com_wrap_variant(rv, &v, obj->code_page TSRMLS_CC);
VariantClear(&v);
}
@@ -145,7 +145,7 @@ static void com_write_dimension(zval *object, zval *offset, zval *value TSRMLS_D
}
convert_to_long(offset);
- indices = Z_LVAL_P(offset);
+ indices = (LONG)Z_LVAL_P(offset);
VariantInit(&v);
php_com_variant_from_zval(&v, value, obj->code_page TSRMLS_CC);
diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c
index 084a720ea1..f0b21ff014 100644
--- a/ext/com_dotnet/com_misc.c
+++ b/ext/com_dotnet/com_misc.c
@@ -36,7 +36,11 @@ void php_com_throw_exception(HRESULT code, char *message TSRMLS_DC)
message = php_win32_error_to_msg(code);
free_msg = 1;
}
+#if SIZEOF_ZEND_LONG == 8
+ zend_throw_exception(php_com_exception_class_entry, message, (zend_long)(uint32_t)code TSRMLS_CC);
+#else
zend_throw_exception(php_com_exception_class_entry, message, (zend_long)code TSRMLS_CC);
+#endif
if (free_msg) {
LocalFree(message);
}
diff --git a/ext/com_dotnet/com_olechar.c b/ext/com_dotnet/com_olechar.c
index 51cc7e8f1d..2e0b558288 100644
--- a/ext/com_dotnet/com_olechar.c
+++ b/ext/com_dotnet/com_olechar.c
@@ -49,7 +49,7 @@ PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, size_t str
/* XXX if that's a real multibyte string, olestring is obviously allocated excessively.
This should be fixed by reallocating the olestring, but as emalloc is used, that doesn't
matter much. */
- ok = MultiByteToWideChar(codepage, flags, string, string_len, olestring, string_len);
+ ok = MultiByteToWideChar(codepage, flags, string, (int)string_len, olestring, (int)string_len);
if (ok > 0 && ok < string_len) {
olestring[ok] = '\0';
}
diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c
index eb80e760c8..dbe8b45300 100644
--- a/ext/com_dotnet/com_persist.c
+++ b/ext/com_dotnet/com_persist.c
@@ -105,10 +105,10 @@ static ULONG STDMETHODCALLTYPE stm_release(IStream *This)
static HRESULT STDMETHODCALLTYPE stm_read(IStream *This, void *pv, ULONG cb, ULONG *pcbRead)
{
- int nread;
+ ULONG nread;
FETCH_STM();
- nread = php_stream_read(stm->stream, pv, cb);
+ nread = (ULONG)php_stream_read(stm->stream, pv, cb);
if (pcbRead) {
*pcbRead = nread > 0 ? nread : 0;
@@ -121,10 +121,10 @@ static HRESULT STDMETHODCALLTYPE stm_read(IStream *This, void *pv, ULONG cb, ULO
static HRESULT STDMETHODCALLTYPE stm_write(IStream *This, void const *pv, ULONG cb, ULONG *pcbWritten)
{
- int nwrote;
+ ULONG nwrote;
FETCH_STM();
- nwrote = php_stream_write(stm->stream, pv, cb);
+ nwrote = (ULONG)php_stream_write(stm->stream, pv, cb);
if (pcbWritten) {
*pcbWritten = nwrote > 0 ? nwrote : 0;
@@ -466,7 +466,7 @@ CPH_METHOD(LoadFromFile)
olefilename = php_com_string_to_olestring(fullpath, strlen(fullpath), helper->codepage TSRMLS_CC);
efree(fullpath);
- res = IPersistFile_Load(helper->ipf, olefilename, flags);
+ res = IPersistFile_Load(helper->ipf, olefilename, (DWORD)flags);
efree(olefilename);
if (FAILED(res)) {
diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c
index ddee9bc179..1d187a77bf 100644
--- a/ext/com_dotnet/com_saproxy.c
+++ b/ext/com_dotnet/com_saproxy.c
@@ -167,11 +167,11 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *
/* copy indices from proxy */
for (i = 0; i < dims; i++) {
convert_to_long(&proxy->indices[i]);
- indices[i] = Z_LVAL(proxy->indices[i]);
+ indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
}
/* add user-supplied index */
- indices[dims-1] = Z_LVAL_P(offset);
+ indices[dims-1] = (LONG)Z_LVAL_P(offset);
/* now fetch the value */
if (FAILED(SafeArrayGetVartype(sa, &vt)) || vt == VT_EMPTY) {
@@ -241,12 +241,12 @@ static void saproxy_write_dimension(zval *object, zval *offset, zval *value TSRM
/* copy indices from proxy */
for (i = 0; i < dims; i++) {
convert_to_long(&proxy->indices[i]);
- indices[i] = Z_LVAL(proxy->indices[i]);
+ indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
}
/* add user-supplied index */
convert_to_long(offset);
- indices[dims-1] = Z_LVAL_P(offset);
+ indices[dims-1] = (LONG)Z_LVAL_P(offset);
if (FAILED(SafeArrayGetVartype(V_ARRAY(&proxy->obj->v), &vt)) || vt == VT_EMPTY) {
vt = V_VT(&proxy->obj->v) & ~VT_ARRAY;
@@ -555,7 +555,7 @@ zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *objec
I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0);
for (i = 0; i < proxy->dimensions; i++) {
convert_to_long(&proxy->indices[i]);
- I->indices[i] = Z_LVAL(proxy->indices[i]);
+ I->indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
}
SafeArrayGetLBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &I->imin);
diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c
index 33b1c65c9c..ac5777cef1 100644
--- a/ext/com_dotnet/com_typeinfo.c
+++ b/ext/com_dotnet/com_typeinfo.c
@@ -71,7 +71,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
if (FAILED(hr) && (major == NULL || minor == NULL)) {
IDispatch *disp = NULL;
ITypeInfo *info = NULL;
- int idx;
+ UINT idx;
if (SUCCEEDED(hr = CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, (LPVOID*)&disp)) &&
SUCCEEDED(hr = IDispatch_GetTypeInfo(disp, 0, LANG_NEUTRAL, &info))) {
@@ -96,7 +96,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
DWORD VersionCount;
char version[20];
char *libname;
- DWORD libnamelen;
+ long libnamelen;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "TypeLib", 0, KEY_READ, &hkey) &&
ERROR_SUCCESS == RegQueryInfoKey(hkey, NULL, NULL, NULL, &SubKeys,
@@ -116,7 +116,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
continue;
}
/* get the default value for this key and compare */
- libnamelen = strlen(search_string)+1;
+ libnamelen = (long)strlen(search_string)+1;
if (ERROR_SUCCESS == RegQueryValue(hsubkey, version, libname, &libnamelen)) {
if (0 == stricmp(libname, search_string)) {
char *str = NULL;
@@ -234,7 +234,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string,
{
ITypeLib *TL;
char *name_dup;
- int l;
+ size_t l;
l = strlen(search_string);
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c
index dbd5529f6d..7317b8d0e4 100644
--- a/ext/com_dotnet/com_variant.c
+++ b/ext/com_dotnet/com_variant.c
@@ -39,8 +39,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
HashPosition pos;
int keytype;
zend_string *strindex;
- zend_long intindex = -1;
- zend_long max_index = 0;
+ zend_ulong intindex = 0;
VARIANT *va;
zval *item;
@@ -54,15 +53,15 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
goto bogus;
} else if (HASH_KEY_NON_EXISTENT == keytype) {
break;
- }
- if (intindex > max_index) {
- max_index = intindex;
+ } else if (intindex > UINT_MAX) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "COM: max number %u of elements in safe array exceeded", UINT_MAX);
+ break;
}
}
/* allocate the structure */
bound.lLbound = 0;
- bound.cElements = intindex + 1;
+ bound.cElements = zend_hash_num_elements(HASH_OF(z));
sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
/* get a lock on the array itself */
@@ -146,8 +145,13 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep
break;
case IS_LONG:
+#if SIZEOF_ZEND_LONG == 4
V_VT(v) = VT_I4;
V_I4(v) = Z_LVAL_P(z);
+#else
+ V_VT(v) = VT_I8;
+ V_I8(v) = Z_LVAL_P(z);
+#endif
break;
case IS_DOUBLE:
@@ -159,9 +163,9 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep
V_VT(v) = VT_BSTR;
olestring = php_com_string_to_olestring(Z_STRVAL_P(z), Z_STRLEN_P(z), codepage TSRMLS_CC);
if (CP_UTF8 == codepage) {
- V_BSTR(v) = SysAllocStringByteLen((char*)olestring, wcslen(olestring) * sizeof(OLECHAR));
+ V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(wcslen(olestring) * sizeof(OLECHAR)));
} else {
- V_BSTR(v) = SysAllocStringByteLen((char*)olestring, Z_STRLEN_P(z) * sizeof(OLECHAR));
+ V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(Z_STRLEN_P(z) * sizeof(OLECHAR)));
}
efree(olestring);
break;
@@ -199,11 +203,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;
@@ -328,7 +340,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);
@@ -428,7 +456,7 @@ PHP_FUNCTION(com_variant_create_instance)
php_com_initialize(TSRMLS_C);
if (ZEND_NUM_ARGS() == 3) {
- obj->code_page = codepage;
+ obj->code_page = (int)codepage;
}
if (zvalue) {
@@ -849,7 +877,7 @@ PHP_FUNCTION(variant_round)
return;
}
- if (SUCCEEDED(VarRound(vleft, decimals, &vres))) {
+ if (SUCCEEDED(VarRound(vleft, (int)decimals, &vres))) {
php_com_wrap_variant(return_value, &vres, codepage TSRMLS_CC);
}
@@ -909,7 +937,7 @@ PHP_FUNCTION(variant_cmp)
return;
}
- ZVAL_LONG(return_value, VarCmp(vleft, vright, lcid, flags));
+ ZVAL_LONG(return_value, VarCmp(vleft, vright, (LCID)lcid, (ULONG)flags));
VariantClear(&left_val);
VariantClear(&right_val);
diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c
index 6112dfb4bf..f7dd7fd463 100644
--- a/ext/com_dotnet/com_wrapper.c
+++ b/ext/com_dotnet/com_wrapper.c
@@ -186,7 +186,7 @@ static HRESULT STDMETHODCALLTYPE disp_getidsofnames(
ret = DISP_E_UNKNOWNNAME;
rgDispId[i] = 0;
} else {
- rgDispId[i] = Z_LVAL_P(tmp);
+ rgDispId[i] = (DISPID)Z_LVAL_P(tmp);
}
efree(name);
@@ -231,7 +231,7 @@ static HRESULT STDMETHODCALLTYPE disp_getdispid(
/* Lookup the name in the hash */
if ((tmp = zend_hash_str_find(disp->name_to_dispid, name, namelen)) != NULL) {
trace("found it\n");
- *pid = Z_LVAL_P(tmp);
+ *pid = (DISPID)Z_LVAL_P(tmp);
ret = S_OK;
}
diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h
index e79e6f586d..e06f50c7d6 100644
--- a/ext/com_dotnet/php_com_dotnet_internal.h
+++ b/ext/com_dotnet/php_com_dotnet_internal.h
@@ -37,8 +37,9 @@ typedef struct _php_com_dotnet_object {
VARIANT v;
int modified;
+ int code_page;
+
ITypeInfo *typeinfo;
- zend_long code_page;
zend_class_entry *ce;
@@ -107,7 +108,7 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
size_t namelen, DISPID *dispid TSRMLS_DC);
int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
WORD flags, VARIANT *v, int nargs, zval *args, int silent, int allow_noarg TSRMLS_DC);
-int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
+int php_com_do_invoke(php_com_dotnet_object *obj, char *name, size_t namelen,
WORD flags, VARIANT *v, int nargs, zval *args, int allow_noarg TSRMLS_DC);
int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *f,
WORD flags, VARIANT *v, int nargs, zval *args TSRMLS_DC);
diff --git a/ext/com_dotnet/tests/bug33386.phpt b/ext/com_dotnet/tests/bug33386.phpt
index e57f1274c1..e7dcd28489 100644
--- a/ext/com_dotnet/tests/bug33386.phpt
+++ b/ext/com_dotnet/tests/bug33386.phpt
@@ -2,7 +2,9 @@
Bug #33386 (ScriptControl only sees last function of class)
--SKIPIF--
<?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 MSScriptControl isn't available under x64";
+?>
--FILE--
<?php
error_reporting(E_ALL);
diff --git a/ext/com_dotnet/tests/variants.phpt b/ext/com_dotnet/tests/variants.phpt
index 0fd27bee5e..6c50beb738 100644
--- a/ext/com_dotnet/tests/variants.phpt
+++ b/ext/com_dotnet/tests/variants.phpt
@@ -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);
diff --git a/ext/com_dotnet/tests/variants_x64.phpt b/ext/com_dotnet/tests/variants_x64.phpt
new file mode 100644
index 0000000000..1c75a9da79
--- /dev/null
+++ b/ext/com_dotnet/tests/variants_x64.phpt
@@ -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!