diff options
Diffstat (limited to 'ext/com_dotnet')
33 files changed, 818 insertions, 741 deletions
diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index ce4bca9d87..99a217342a 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -28,7 +26,7 @@ #include "Zend/zend_exceptions.h" /* {{{ com_create_instance - ctor for COM class */ -PHP_FUNCTION(com_create_instance) +PHP_METHOD(com, __construct) { zval *object = getThis(); zval *server_params = NULL; @@ -53,26 +51,24 @@ PHP_FUNCTION(com_create_instance) zend_long cp = GetACP(); const struct php_win32_cp *cp_it; - php_com_initialize(); - obj = CDNO_FETCH(object); - if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "s|s!ls", &module_name, &module_name_len, &server_name, &server_name_len, &cp, &typelib_name, &typelib_name_len) && - FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, + FAILURE == zend_parse_parameters( ZEND_NUM_ARGS(), "sa/|ls", &module_name, &module_name_len, &server_params, &cp, &typelib_name, &typelib_name_len)) { - - php_com_throw_exception(E_INVALIDARG, "Could not create COM object - invalid arguments!"); - return; + RETURN_THROWS(); } + php_com_initialize(); + obj = CDNO_FETCH(object); + cp_it = php_win32_cp_get_by_id((DWORD)cp); if (!cp_it) { php_com_throw_exception(E_INVALIDARG, "Could not create COM object - invalid codepage!"); - return; + RETURN_THROWS(); } obj->code_page = (int)cp; @@ -86,7 +82,7 @@ PHP_FUNCTION(com_create_instance) if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params), "Server", sizeof("Server")-1))) { if (!try_convert_to_string(tmp)) { - return; + RETURN_THROWS(); } server_name = Z_STRVAL_P(tmp); server_name_len = Z_STRLEN_P(tmp); @@ -96,7 +92,7 @@ PHP_FUNCTION(com_create_instance) if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params), "Username", sizeof("Username")-1))) { if (!try_convert_to_string(tmp)) { - return; + RETURN_THROWS(); } user_name = Z_STRVAL_P(tmp); user_name_len = Z_STRLEN_P(tmp); @@ -105,7 +101,7 @@ PHP_FUNCTION(com_create_instance) if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params), "Password", sizeof("Password")-1))) { if (!try_convert_to_string(tmp)) { - return; + RETURN_THROWS(); } password = Z_STRVAL_P(tmp); password_len = Z_STRLEN_P(tmp); @@ -114,7 +110,7 @@ PHP_FUNCTION(com_create_instance) if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params), "Domain", sizeof("Domain")-1))) { if (!try_convert_to_string(tmp)) { - return; + RETURN_THROWS(); } domain_name = Z_STRVAL_P(tmp); domain_name_len = Z_STRLEN_P(tmp); @@ -128,7 +124,7 @@ PHP_FUNCTION(com_create_instance) if (server_name && !COMG(allow_dcom)) { php_com_throw_exception(E_ERROR, "DCOM has been disabled by your administrator [com.allow_dcom=0]"); - return; + RETURN_THROWS(); } moniker = php_com_string_to_olestring(module_name, module_name_len, obj->code_page); @@ -242,7 +238,7 @@ PHP_FUNCTION(com_create_instance) php_com_throw_exception(res, msg); efree(msg); - return; + RETURN_THROWS(); } /* we got the object and it lives ! */ @@ -250,9 +246,7 @@ PHP_FUNCTION(com_create_instance) /* see if it has TypeInfo available */ if (FAILED(IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &obj->typeinfo)) && typelib_name) { /* load up the library from the named file */ - int cached; - - TL = php_com_load_typelib_via_cache(typelib_name, obj->code_page, &cached); + TL = php_com_load_typelib_via_cache(typelib_name, obj->code_page); if (TL) { if (COMG(autoreg_on)) { @@ -293,24 +287,27 @@ PHP_FUNCTION(com_create_instance) } /* }}} */ -/* {{{ proto object com_get_active_object(string progid [, int code_page ]) - Returns a handle to an already running instance of a COM object */ +/* {{{ Returns a handle to an already running instance of a COM object */ PHP_FUNCTION(com_get_active_object) { CLSID clsid; char *module_name; size_t module_name_len; - zend_long code_page = COMG(code_page); + zend_long code_page; + zend_bool code_page_is_null = 1; IUnknown *unk = NULL; IDispatch *obj = NULL; HRESULT res; OLECHAR *module = NULL; php_com_initialize(); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", - &module_name, &module_name_len, &code_page)) { - php_com_throw_exception(E_INVALIDARG, "Invalid arguments!"); - return; + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|l!", + &module_name, &module_name_len, &code_page, &code_page_is_null)) { + RETURN_THROWS(); + } + + if (code_page_is_null) { + code_page = COMG(code_page); } module = php_com_string_to_olestring(module_name, module_name_len, (int)code_page); @@ -509,7 +506,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * if (f->arg_info) { for (i = 0; i < nargs; i++) { - if (f->arg_info[nargs - i - 1].pass_by_reference) { + if (ZEND_ARG_SEND_MODE(&f->arg_info[nargs - i - 1])) { byref_count++; } } @@ -518,7 +515,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * if (byref_count) { byref_vals = (VARIANT*)safe_emalloc(sizeof(VARIANT), byref_count, 0); for (j = 0, i = 0; i < nargs; i++) { - if (f->arg_info[nargs - i - 1].pass_by_reference) { + if (ZEND_ARG_SEND_MODE(&f->arg_info[nargs - i - 1])) { /* put the value into byref_vals instead */ php_com_variant_from_zval(&byref_vals[j], &args[nargs - i - 1], obj->code_page); @@ -565,7 +562,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * 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) { + if (ZEND_ARG_SEND_MODE(&f->arg_info[nargs - i - 1])) { zval *arg = &args[nargs - i - 1]; ZVAL_DEREF(arg); @@ -672,15 +669,14 @@ int php_com_do_invoke(php_com_dotnet_object *obj, char *name, size_t namelen, return php_com_do_invoke_by_id(obj, dispid, flags, v, nargs, args, 0, allow_noarg); } -/* {{{ proto string com_create_guid() - Generate a globally unique identifier (GUID) */ +/* {{{ Generate a globally unique identifier (GUID) */ PHP_FUNCTION(com_create_guid) { GUID retval; OLECHAR *guid_string; if (zend_parse_parameters_none() == FAILURE) { - return; + RETURN_THROWS(); } php_com_initialize(); @@ -700,8 +696,7 @@ PHP_FUNCTION(com_create_guid) } /* }}} */ -/* {{{ proto bool com_event_sink(object comobject, object sinkobject [, mixed sinkinterface]) - Connect events from a COM object to a PHP object */ +/* {{{ Connect events from a COM object to a PHP object */ PHP_FUNCTION(com_event_sink) { zval *object, *sinkobject, *sink=NULL; @@ -713,7 +708,7 @@ PHP_FUNCTION(com_event_sink) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oo|z/", &object, php_com_variant_class_entry, &sinkobject, &sink)) { - RETURN_FALSE; + RETURN_THROWS(); } php_com_initialize(); @@ -729,7 +724,7 @@ PHP_FUNCTION(com_event_sink) dispname = Z_STRVAL_P(tmp); } else if (sink != NULL) { if (!try_convert_to_string(sink)) { - return; + RETURN_THROWS(); } dispname = Z_STRVAL_P(sink); } @@ -762,8 +757,7 @@ PHP_FUNCTION(com_event_sink) } /* }}} */ -/* {{{ proto bool com_print_typeinfo(object comobject | string typelib, string dispinterface, bool wantsink) - Print out a PHP class definition for a dispatchable interface */ +/* {{{ Print out a PHP class definition for a dispatchable interface */ PHP_FUNCTION(com_print_typeinfo) { zval *arg1; @@ -776,7 +770,7 @@ PHP_FUNCTION(com_print_typeinfo) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "z/|s!b", &arg1, &ifacename, &ifacelen, &wantsink)) { - RETURN_FALSE; + RETURN_THROWS(); } php_com_initialize(); @@ -799,8 +793,7 @@ PHP_FUNCTION(com_print_typeinfo) } /* }}} */ -/* {{{ proto bool com_message_pump([int timeoutms]) - Process COM messages, sleeping for up to timeoutms milliseconds */ +/* {{{ Process COM messages, sleeping for up to timeoutms milliseconds */ PHP_FUNCTION(com_message_pump) { zend_long timeoutms = 0; @@ -808,7 +801,7 @@ PHP_FUNCTION(com_message_pump) DWORD result; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &timeoutms) == FAILURE) - RETURN_FALSE; + RETURN_THROWS(); php_com_initialize(); result = MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD)timeoutms, QS_ALLINPUT); @@ -827,8 +820,7 @@ PHP_FUNCTION(com_message_pump) } /* }}} */ -/* {{{ proto bool com_load_typelib(string typelib_name [, bool case_insensitive]) - Loads a Typelibrary and registers its constants */ +/* {{{ Loads a Typelibrary and registers its constants */ PHP_FUNCTION(com_load_typelib) { char *name; @@ -836,20 +828,19 @@ PHP_FUNCTION(com_load_typelib) ITypeLib *pTL = NULL; zend_bool cs = TRUE; int codepage = COMG(code_page); - int cached = 0; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &name, &namelen, &cs)) { - return; + RETURN_THROWS(); } if (!cs) { - php_error_docref(NULL, E_DEPRECATED, "Declaration of case-insensitive constants is deprecated"); + php_error_docref(NULL, E_WARNING, "com_load_typelib(): Argument #2 ($case_insensitive) is ignored since declaration of case-insensitive constants is no longer supported"); } RETVAL_FALSE; php_com_initialize(); - pTL = php_com_load_typelib_via_cache(name, codepage, &cached); + pTL = php_com_load_typelib_via_cache(name, codepage); if (pTL) { if (php_com_import_typelib(pTL, cs ? CONST_CS : 0, codepage) == SUCCESS) { RETVAL_TRUE; diff --git a/ext/com_dotnet/com_dotnet.c b/ext/com_dotnet/com_dotnet.c index 7222615986..1b0ba2220c 100644 --- a/ext/com_dotnet/com_dotnet.c +++ b/ext/com_dotnet/com_dotnet.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -119,6 +117,44 @@ struct dotnet_runtime_stuff { DISPID create_instance; }; +/* We link dynamically to mscoree.dll to avoid the hard dependency on .NET + * framework, which is only required if a dotnet instance is to be created. + */ +static HRESULT dotnet_bind_runtime(LPVOID FAR *ppv) +{ + HRESULT hr; + HMODULE mscoree; + typedef HRESULT (STDAPICALLTYPE *cbtr_t)(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv); + cbtr_t CorBindToRuntime; + OLECHAR *oleversion; + char *version; + + mscoree = LoadLibraryA("mscoree.dll"); + if (mscoree == NULL) { + return S_FALSE; + } + + CorBindToRuntime = (cbtr_t) GetProcAddress(mscoree, "CorBindToRuntime"); + if (CorBindToRuntime == NULL) { + FreeLibrary(mscoree); + return S_FALSE; + } + + version = INI_STR("com.dotnet_version"); + if (version == NULL || *version == '\0') { + oleversion = NULL; + } else { + oleversion = php_com_string_to_olestring(version, strlen(version), COMG(code_page)); + } + + hr = CorBindToRuntime(oleversion, NULL, &CLSID_CorRuntimeHost, &IID_ICorRuntimeHost, ppv); + + efree(oleversion); + FreeLibrary(mscoree); + + return hr; +} + static HRESULT dotnet_init(char **p_where) { HRESULT hr; @@ -132,10 +168,8 @@ static HRESULT dotnet_init(char **p_where) } memset(stuff, 0, sizeof(*stuff)); - where = "CoCreateInstance"; - hr = CoCreateInstance(&CLSID_CorRuntimeHost, NULL, CLSCTX_ALL, - &IID_ICorRuntimeHost, (LPVOID*)&stuff->dotnet_host); - + where = "dotnet_bind_runtime"; + hr = dotnet_bind_runtime((LPVOID*)&stuff->dotnet_host); if (FAILED(hr)) goto out; @@ -181,7 +215,7 @@ out: } /* {{{ com_dotnet_create_instance - ctor for DOTNET class */ -PHP_FUNCTION(com_dotnet_create_instance) +PHP_METHOD(dotnet, __construct) { zval *object = getThis(); php_com_dotnet_object *obj; @@ -197,6 +231,13 @@ PHP_FUNCTION(com_dotnet_create_instance) zend_long cp = GetACP(); const struct php_win32_cp *cp_it; + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ss|l", + &assembly_name, &assembly_name_len, + &datatype_name, &datatype_name_len, + &cp)) { + RETURN_THROWS(); + } + php_com_initialize(); stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff); if (stuff == NULL) { @@ -207,7 +248,7 @@ PHP_FUNCTION(com_dotnet_create_instance) snprintf(buf, sizeof(buf), "Failed to init .Net runtime [%s] %s", where, err); php_win32_error_msg_free(err); php_com_throw_exception(hr, buf); - return; + RETURN_THROWS(); } stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff); @@ -221,7 +262,7 @@ PHP_FUNCTION(com_dotnet_create_instance) php_win32_error_msg_free(err); php_com_throw_exception(hr, buf); ZVAL_NULL(object); - return; + RETURN_THROWS(); } where = "QI: System._AppDomain"; @@ -233,24 +274,16 @@ PHP_FUNCTION(com_dotnet_create_instance) php_win32_error_msg_free(err); php_com_throw_exception(hr, buf); ZVAL_NULL(object); - return; + RETURN_THROWS(); } } obj = CDNO_FETCH(object); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ss|l", - &assembly_name, &assembly_name_len, - &datatype_name, &datatype_name_len, - &cp)) { - php_com_throw_exception(E_INVALIDARG, "Could not create .Net object - invalid arguments!"); - return; - } - cp_it = php_win32_cp_get_by_id((DWORD)cp); if (!cp_it) { php_com_throw_exception(E_INVALIDARG, "Could not create .Net object - invalid codepage!"); - return; + RETURN_THROWS(); } obj->code_page = (int)cp_it->id; @@ -314,7 +347,7 @@ PHP_FUNCTION(com_dotnet_create_instance) snprintf(buf, sizeof(buf), "Failed to instantiate .Net object [%s] [0x%08x] %s", where, hr, err); php_win32_error_msg_free(err); php_com_throw_exception(hr, buf); - return; + RETURN_THROWS(); } } /* }}} */ diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c index 5ae14815dd..5e2c1f69de 100644 --- a/ext/com_dotnet/com_extension.c +++ b/ext/com_dotnet/com_extension.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -29,6 +27,7 @@ #include "php_com_dotnet_internal.h" #include "Zend/zend_exceptions.h" #include "Zend/zend_interfaces.h" +#include "com_extension_arginfo.h" ZEND_DECLARE_MODULE_GLOBALS(com_dotnet) static PHP_GINIT_FUNCTION(com_dotnet); @@ -38,144 +37,11 @@ zend_class_entry *php_com_exception_class_entry, *php_com_saproxy_class_entry; -/* {{{ arginfo */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_set, 0, 0, 2) - ZEND_ARG_INFO(0, variant) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_left_right, 0, 0, 2) - ZEND_ARG_INFO(0, left) - ZEND_ARG_INFO(0, right) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_abs, 0, 0, 1) - ZEND_ARG_INFO(0, left) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_fix, 0, 0, 1) - ZEND_ARG_INFO(0, left) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_int, 0, 0, 1) - ZEND_ARG_INFO(0, left) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_neg, 0, 0, 1) - ZEND_ARG_INFO(0, left) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_not, 0, 0, 1) - ZEND_ARG_INFO(0, left) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_round, 0, 0, 2) - ZEND_ARG_INFO(0, left) - ZEND_ARG_INFO(0, decimals) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_cmp, 0, 0, 2) - ZEND_ARG_INFO(0, left) - ZEND_ARG_INFO(0, right) - ZEND_ARG_INFO(0, lcid) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_date_to_timestamp, 0, 0, 1) - ZEND_ARG_INFO(0, variant) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_date_from_timestamp, 0, 0, 1) - ZEND_ARG_INFO(0, timestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_get_type, 0, 0, 1) - ZEND_ARG_INFO(0, variant) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_set_type, 0, 0, 2) - ZEND_ARG_INFO(0, variant) - ZEND_ARG_INFO(0, type) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_variant_cast, 0, 0, 2) - ZEND_ARG_INFO(0, variant) - ZEND_ARG_INFO(0, type) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_com_get_active_object, 0, 0, 1) - ZEND_ARG_INFO(0, progid) - ZEND_ARG_INFO(0, code_page) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_com_create_guid, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_com_event_sink, 0, 0, 2) - ZEND_ARG_INFO(0, comobject) - ZEND_ARG_INFO(0, sinkobject) - ZEND_ARG_INFO(0, sinkinterface) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_com_print_typeinfo, 0, 0, 1) - ZEND_ARG_INFO(0, comobject) - ZEND_ARG_INFO(0, dispinterface) - ZEND_ARG_INFO(0, wantsink) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_com_message_pump, 0, 0, 0) - ZEND_ARG_INFO(0, timeoutms) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_com_load_typelib, 0, 0, 1) - ZEND_ARG_INFO(0, typelib_name) - ZEND_ARG_INFO(0, case_insensitive) -ZEND_END_ARG_INFO() -/* }}} */ - -static const zend_function_entry com_dotnet_functions[] = { - PHP_FE(variant_set, arginfo_variant_set) - PHP_FE(variant_add, arginfo_left_right) - PHP_FE(variant_cat, arginfo_left_right) - PHP_FE(variant_sub, arginfo_left_right) - PHP_FE(variant_mul, arginfo_left_right) - PHP_FE(variant_and, arginfo_left_right) - PHP_FE(variant_div, arginfo_left_right) - PHP_FE(variant_eqv, arginfo_left_right) - PHP_FE(variant_idiv, arginfo_left_right) - PHP_FE(variant_imp, arginfo_left_right) - PHP_FE(variant_mod, arginfo_left_right) - PHP_FE(variant_or, arginfo_left_right) - PHP_FE(variant_pow, arginfo_left_right) - PHP_FE(variant_xor, arginfo_left_right) - PHP_FE(variant_abs, arginfo_variant_abs) - PHP_FE(variant_fix, arginfo_variant_fix) - PHP_FE(variant_int, arginfo_variant_int) - PHP_FE(variant_neg, arginfo_variant_neg) - PHP_FE(variant_not, arginfo_variant_not) - PHP_FE(variant_round, arginfo_variant_round) - PHP_FE(variant_cmp, arginfo_variant_cmp) - PHP_FE(variant_date_to_timestamp, arginfo_variant_date_to_timestamp) - PHP_FE(variant_date_from_timestamp, arginfo_variant_date_from_timestamp) - PHP_FE(variant_get_type, arginfo_variant_get_type) - PHP_FE(variant_set_type, arginfo_variant_set_type) - PHP_FE(variant_cast, arginfo_variant_cast) - /* com_com.c */ - PHP_FE(com_create_guid, arginfo_com_create_guid) - PHP_FE(com_event_sink, arginfo_com_event_sink) - PHP_FE(com_print_typeinfo, arginfo_com_print_typeinfo) - PHP_FE(com_message_pump, arginfo_com_message_pump) - PHP_FE(com_load_typelib, arginfo_com_load_typelib) - PHP_FE(com_get_active_object, arginfo_com_get_active_object) - PHP_FE_END -}; - -/* {{{ com_dotnet_module_entry - */ +/* {{{ com_dotnet_module_entry */ zend_module_entry com_dotnet_module_entry = { STANDARD_MODULE_HEADER, "com_dotnet", - com_dotnet_functions, + ext_functions, PHP_MINIT(com_dotnet), PHP_MSHUTDOWN(com_dotnet), PHP_RINIT(com_dotnet), @@ -197,8 +63,7 @@ ZEND_TSRMLS_CACHE_DEFINE() ZEND_GET_MODULE(com_dotnet) #endif -/* {{{ PHP_INI - */ +/* {{{ PHP_INI */ /* com.typelib_file is the path to a file containing a * list of typelibraries to register *persistently*. @@ -210,7 +75,6 @@ static PHP_INI_MH(OnTypeLibFileUpdate) FILE *typelib_file; char *typelib_name_buffer; char *strtok_buf = NULL; - int cached; if (NULL == new_value || !new_value->val[0] || (typelib_file = VCWD_FOPEN(new_value->val, "r"))==NULL) { return FAILURE; @@ -235,8 +99,7 @@ static PHP_INI_MH(OnTypeLibFileUpdate) modifier = php_strtok_r(NULL, "#", &strtok_buf); if (modifier != NULL) { if (!strcmp(modifier, "cis") || !strcmp(modifier, "case_insensitive")) { - php_error_docref("com.configuration", E_DEPRECATED, "Declaration of case-insensitive constants is deprecated"); - mode &= ~CONST_CS; + php_error_docref("com.configuration", E_WARNING, "Declaration of case-insensitive constants is no longer supported; #cis modifier ignored"); } } @@ -250,7 +113,7 @@ static PHP_INI_MH(OnTypeLibFileUpdate) ptr--; } - if ((pTL = php_com_load_typelib_via_cache(typelib_name, COMG(code_page), &cached)) != NULL) { + if ((pTL = php_com_load_typelib_via_cache(typelib_name, COMG(code_page))) != NULL) { php_com_import_typelib(pTL, mode, COMG(code_page)); ITypeLib_Release(pTL); } @@ -265,23 +128,24 @@ static PHP_INI_MH(OnTypeLibFileUpdate) static ZEND_INI_MH(OnAutoregisterCasesensitive) { if (!zend_ini_parse_bool(new_value)) { - php_error_docref("com.configuration", E_DEPRECATED, "Declaration of case-insensitive constants is deprecated"); + php_error_docref("com.configuration", E_WARNING, "Declaration of case-insensitive constants is no longer supported"); + return FAILURE; } return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("com.allow_dcom", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_dcom, zend_com_dotnet_globals, com_dotnet_globals) - STD_PHP_INI_ENTRY("com.autoregister_verbose", "0", PHP_INI_ALL, OnUpdateBool, autoreg_verbose, zend_com_dotnet_globals, com_dotnet_globals) - STD_PHP_INI_ENTRY("com.autoregister_typelib", "0", PHP_INI_ALL, OnUpdateBool, autoreg_on, zend_com_dotnet_globals, com_dotnet_globals) + STD_PHP_INI_BOOLEAN("com.allow_dcom", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_dcom, zend_com_dotnet_globals, com_dotnet_globals) + STD_PHP_INI_BOOLEAN("com.autoregister_verbose", "0", PHP_INI_ALL, OnUpdateBool, autoreg_verbose, zend_com_dotnet_globals, com_dotnet_globals) + STD_PHP_INI_BOOLEAN("com.autoregister_typelib", "0", PHP_INI_ALL, OnUpdateBool, autoreg_on, zend_com_dotnet_globals, com_dotnet_globals) STD_PHP_INI_ENTRY("com.autoregister_casesensitive", "1", PHP_INI_ALL, OnAutoregisterCasesensitive, autoreg_case_sensitive, zend_com_dotnet_globals, com_dotnet_globals) STD_PHP_INI_ENTRY("com.code_page", "", PHP_INI_ALL, OnUpdateLong, code_page, zend_com_dotnet_globals, com_dotnet_globals) PHP_INI_ENTRY("com.typelib_file", "", PHP_INI_SYSTEM, OnTypeLibFileUpdate) + PHP_INI_ENTRY("com.dotnet_version", NULL, PHP_INI_SYSTEM, NULL) PHP_INI_END() /* }}} */ -/* {{{ PHP_GINIT_FUNCTION - */ +/* {{{ PHP_GINIT_FUNCTION */ static PHP_GINIT_FUNCTION(com_dotnet) { #if defined(COMPILE_DL_COM_DOTNET) && defined(ZTS) @@ -292,8 +156,7 @@ static PHP_GINIT_FUNCTION(com_dotnet) } /* }}} */ -/* {{{ PHP_MINIT_FUNCTION - */ +/* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(com_dotnet) { zend_class_entry ce, *tmp; @@ -312,14 +175,14 @@ PHP_MINIT_FUNCTION(com_dotnet) /* php_com_saproxy_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED; */ php_com_saproxy_class_entry->get_iterator = php_com_saproxy_iter_get; - INIT_CLASS_ENTRY(ce, "variant", NULL); + INIT_CLASS_ENTRY(ce, "variant", class_variant_methods); ce.create_object = php_com_object_new; php_com_variant_class_entry = zend_register_internal_class(&ce); php_com_variant_class_entry->get_iterator = php_com_iter_get; php_com_variant_class_entry->serialize = zend_class_serialize_deny; php_com_variant_class_entry->unserialize = zend_class_unserialize_deny; - INIT_CLASS_ENTRY(ce, "com", NULL); + INIT_CLASS_ENTRY(ce, "com", class_com_methods); ce.create_object = php_com_object_new; tmp = zend_register_internal_class_ex(&ce, php_com_variant_class_entry); tmp->get_iterator = php_com_iter_get; @@ -327,7 +190,7 @@ PHP_MINIT_FUNCTION(com_dotnet) tmp->unserialize = zend_class_unserialize_deny; #if HAVE_MSCOREE_H - INIT_CLASS_ENTRY(ce, "dotnet", NULL); + INIT_CLASS_ENTRY(ce, "dotnet", class_dotnet_methods); ce.create_object = php_com_object_new; tmp = zend_register_internal_class_ex(&ce, php_com_variant_class_entry); tmp->get_iterator = php_com_iter_get; @@ -340,11 +203,7 @@ PHP_MINIT_FUNCTION(com_dotnet) #define COM_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_CS|CONST_PERSISTENT) #if SIZEOF_ZEND_LONG == 8 -# define COM_ERR_CONST(x) { \ - zend_long __tmp; \ - ULongToIntPtr(x, &__tmp); \ - REGISTER_LONG_CONSTANT(#x, __tmp, CONST_CS|CONST_PERSISTENT); \ -} +# define COM_ERR_CONST(x) REGISTER_LONG_CONSTANT(#x, (zend_long) (ULONG) (x), CONST_CS|CONST_PERSISTENT) #else # define COM_ERR_CONST COM_CONST #endif @@ -398,6 +257,7 @@ PHP_MINIT_FUNCTION(com_dotnet) COM_CONST(VARCMP_EQ); COM_CONST(VARCMP_GT); COM_CONST(VARCMP_NULL); + COM_CONST(LOCALE_SYSTEM_DEFAULT); COM_CONST(NORM_IGNORECASE); COM_CONST(NORM_IGNORENONSPACE); @@ -423,8 +283,7 @@ PHP_MINIT_FUNCTION(com_dotnet) } /* }}} */ -/* {{{ PHP_MSHUTDOWN_FUNCTION - */ +/* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(com_dotnet) { UNREGISTER_INI_ENTRIES(); @@ -440,8 +299,7 @@ PHP_MSHUTDOWN_FUNCTION(com_dotnet) } /* }}} */ -/* {{{ PHP_RINIT_FUNCTION - */ +/* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(com_dotnet) { COMG(rshutdown_started) = 0; @@ -449,8 +307,7 @@ PHP_RINIT_FUNCTION(com_dotnet) } /* }}} */ -/* {{{ PHP_RSHUTDOWN_FUNCTION - */ +/* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(com_dotnet) { #if HAVE_MSCOREE_H @@ -463,8 +320,7 @@ PHP_RSHUTDOWN_FUNCTION(com_dotnet) } /* }}} */ -/* {{{ PHP_MINFO_FUNCTION - */ +/* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(com_dotnet) { php_info_print_table_start(); diff --git a/ext/com_dotnet/com_extension.stub.php b/ext/com_dotnet/com_extension.stub.php new file mode 100644 index 0000000000..8323b0796b --- /dev/null +++ b/ext/com_dotnet/com_extension.stub.php @@ -0,0 +1,87 @@ +<?php + +/** @generate-function-entries */ + +function variant_set(variant $variant, mixed $value): void {} + +function variant_add(mixed $left, mixed $right): variant {} + +function variant_cat(mixed $left, mixed $right): variant {} + +function variant_sub(mixed $left, mixed $right): variant {} + +function variant_mul(mixed $left, mixed $right): variant {} + +function variant_and(mixed $left, mixed $right): variant {} + +function variant_div(mixed $left, mixed $right): variant {} + +function variant_eqv(mixed $left, mixed $right): variant {} + +function variant_idiv(mixed $left, mixed $right): variant {} + +function variant_imp(mixed $left, mixed $right): variant {} + +function variant_mod(mixed $left, mixed $right): variant {} + +function variant_or(mixed $left, mixed $right): variant {} + +function variant_pow(mixed $left, mixed $right): variant {} + +function variant_xor(mixed $left, mixed $right): variant {} + +function variant_abs(mixed $left): variant {} + +function variant_fix(mixed $left): variant {} + +function variant_int(mixed $left): variant {} + +function variant_neg(mixed $left): variant {} + +function variant_not(mixed $left): variant {} + +function variant_round(mixed $left, int $decimals): ?variant {} + +function variant_cmp(mixed $left, mixed $right, int $lcid = LOCALE_SYSTEM_DEFAULT, int $flags = 0): int {} + +function variant_date_to_timestamp(variant $variant): ?int {} + +function variant_date_from_timestamp(int $timestamp): variant|false {} + +function variant_get_type(variant $variant): int {} + +function variant_set_type(variant $variant, int $type): void {} + +function variant_cast(variant $variant, int $type): variant {} + +function com_get_active_object(string $progid, ?int $code_page = null): variant {} + +function com_create_guid(): string|false {} + +/** @param array|string|null $sinkinterface */ +function com_event_sink(variant $comobject, object $sinkobject, $sinkinterface = UNKNOWN): bool {} + +/** @param com|dotnet|variant|string $comobject */ +function com_print_typeinfo($comobject, ?string $dispinterface = null, bool $wantsink = false): bool {} + +function com_message_pump(int $timeoutms = 0): bool {} + +function com_load_typelib(string $typelib_name, bool $case_insensitive = true): bool {} + +class variant +{ + public function __construct(mixed $value = null, int $type = VT_EMPTY, int $codepage = CP_ACP) {} +} + +class com +{ + /** @param string|array|null $server_name */ + public function __construct(string $module_name, $server_name = UNKNOWN, int $codepage = CP_ACP, string $typelib = "") {} +} + +#if HAVE_MSCOREE_H +class dotnet +{ + public function __construct(string $assembly_name, string $datatype_name, int $codepage = CP_ACP) {} +} +#endif diff --git a/ext/com_dotnet/com_extension_arginfo.h b/ext/com_dotnet/com_extension_arginfo.h new file mode 100644 index 0000000000..aec8108d88 --- /dev/null +++ b/ext/com_dotnet/com_extension_arginfo.h @@ -0,0 +1,228 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 48167f9ee38966beaf550cd0a7b07d873575b48e */ + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_variant_set, 0, 2, IS_VOID, 0) + ZEND_ARG_OBJ_INFO(0, variant, variant, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_variant_add, 0, 2, variant, 0) + ZEND_ARG_TYPE_INFO(0, left, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, right, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +#define arginfo_variant_cat arginfo_variant_add + +#define arginfo_variant_sub arginfo_variant_add + +#define arginfo_variant_mul arginfo_variant_add + +#define arginfo_variant_and arginfo_variant_add + +#define arginfo_variant_div arginfo_variant_add + +#define arginfo_variant_eqv arginfo_variant_add + +#define arginfo_variant_idiv arginfo_variant_add + +#define arginfo_variant_imp arginfo_variant_add + +#define arginfo_variant_mod arginfo_variant_add + +#define arginfo_variant_or arginfo_variant_add + +#define arginfo_variant_pow arginfo_variant_add + +#define arginfo_variant_xor arginfo_variant_add + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_variant_abs, 0, 1, variant, 0) + ZEND_ARG_TYPE_INFO(0, left, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +#define arginfo_variant_fix arginfo_variant_abs + +#define arginfo_variant_int arginfo_variant_abs + +#define arginfo_variant_neg arginfo_variant_abs + +#define arginfo_variant_not arginfo_variant_abs + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_variant_round, 0, 2, variant, 1) + ZEND_ARG_TYPE_INFO(0, left, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, decimals, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_variant_cmp, 0, 2, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, left, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, right, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, lcid, IS_LONG, 0, "LOCALE_SYSTEM_DEFAULT") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_variant_date_to_timestamp, 0, 1, IS_LONG, 1) + ZEND_ARG_OBJ_INFO(0, variant, variant, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_variant_date_from_timestamp, 0, 1, variant, MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_variant_get_type, 0, 1, IS_LONG, 0) + ZEND_ARG_OBJ_INFO(0, variant, variant, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_variant_set_type, 0, 2, IS_VOID, 0) + ZEND_ARG_OBJ_INFO(0, variant, variant, 0) + ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_variant_cast, 0, 2, variant, 0) + ZEND_ARG_OBJ_INFO(0, variant, variant, 0) + ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_com_get_active_object, 0, 1, variant, 0) + ZEND_ARG_TYPE_INFO(0, progid, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code_page, IS_LONG, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_com_create_guid, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_com_event_sink, 0, 2, _IS_BOOL, 0) + ZEND_ARG_OBJ_INFO(0, comobject, variant, 0) + ZEND_ARG_TYPE_INFO(0, sinkobject, IS_OBJECT, 0) + ZEND_ARG_INFO(0, sinkinterface) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_com_print_typeinfo, 0, 1, _IS_BOOL, 0) + ZEND_ARG_INFO(0, comobject) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, dispinterface, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, wantsink, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_com_message_pump, 0, 0, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeoutms, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_com_load_typelib, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, typelib_name, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, case_insensitive, _IS_BOOL, 0, "true") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_variant___construct, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, IS_MIXED, 0, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "VT_EMPTY") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, codepage, IS_LONG, 0, "CP_ACP") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_com___construct, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, module_name, IS_STRING, 0) + ZEND_ARG_INFO(0, server_name) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, codepage, IS_LONG, 0, "CP_ACP") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, typelib, IS_STRING, 0, "\"\"") +ZEND_END_ARG_INFO() + +#if HAVE_MSCOREE_H +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_dotnet___construct, 0, 0, 2) + ZEND_ARG_TYPE_INFO(0, assembly_name, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, datatype_name, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, codepage, IS_LONG, 0, "CP_ACP") +ZEND_END_ARG_INFO() +#endif + + +ZEND_FUNCTION(variant_set); +ZEND_FUNCTION(variant_add); +ZEND_FUNCTION(variant_cat); +ZEND_FUNCTION(variant_sub); +ZEND_FUNCTION(variant_mul); +ZEND_FUNCTION(variant_and); +ZEND_FUNCTION(variant_div); +ZEND_FUNCTION(variant_eqv); +ZEND_FUNCTION(variant_idiv); +ZEND_FUNCTION(variant_imp); +ZEND_FUNCTION(variant_mod); +ZEND_FUNCTION(variant_or); +ZEND_FUNCTION(variant_pow); +ZEND_FUNCTION(variant_xor); +ZEND_FUNCTION(variant_abs); +ZEND_FUNCTION(variant_fix); +ZEND_FUNCTION(variant_int); +ZEND_FUNCTION(variant_neg); +ZEND_FUNCTION(variant_not); +ZEND_FUNCTION(variant_round); +ZEND_FUNCTION(variant_cmp); +ZEND_FUNCTION(variant_date_to_timestamp); +ZEND_FUNCTION(variant_date_from_timestamp); +ZEND_FUNCTION(variant_get_type); +ZEND_FUNCTION(variant_set_type); +ZEND_FUNCTION(variant_cast); +ZEND_FUNCTION(com_get_active_object); +ZEND_FUNCTION(com_create_guid); +ZEND_FUNCTION(com_event_sink); +ZEND_FUNCTION(com_print_typeinfo); +ZEND_FUNCTION(com_message_pump); +ZEND_FUNCTION(com_load_typelib); +ZEND_METHOD(variant, __construct); +ZEND_METHOD(com, __construct); +#if HAVE_MSCOREE_H +ZEND_METHOD(dotnet, __construct); +#endif + + +static const zend_function_entry ext_functions[] = { + ZEND_FE(variant_set, arginfo_variant_set) + ZEND_FE(variant_add, arginfo_variant_add) + ZEND_FE(variant_cat, arginfo_variant_cat) + ZEND_FE(variant_sub, arginfo_variant_sub) + ZEND_FE(variant_mul, arginfo_variant_mul) + ZEND_FE(variant_and, arginfo_variant_and) + ZEND_FE(variant_div, arginfo_variant_div) + ZEND_FE(variant_eqv, arginfo_variant_eqv) + ZEND_FE(variant_idiv, arginfo_variant_idiv) + ZEND_FE(variant_imp, arginfo_variant_imp) + ZEND_FE(variant_mod, arginfo_variant_mod) + ZEND_FE(variant_or, arginfo_variant_or) + ZEND_FE(variant_pow, arginfo_variant_pow) + ZEND_FE(variant_xor, arginfo_variant_xor) + ZEND_FE(variant_abs, arginfo_variant_abs) + ZEND_FE(variant_fix, arginfo_variant_fix) + ZEND_FE(variant_int, arginfo_variant_int) + ZEND_FE(variant_neg, arginfo_variant_neg) + ZEND_FE(variant_not, arginfo_variant_not) + ZEND_FE(variant_round, arginfo_variant_round) + ZEND_FE(variant_cmp, arginfo_variant_cmp) + ZEND_FE(variant_date_to_timestamp, arginfo_variant_date_to_timestamp) + ZEND_FE(variant_date_from_timestamp, arginfo_variant_date_from_timestamp) + ZEND_FE(variant_get_type, arginfo_variant_get_type) + ZEND_FE(variant_set_type, arginfo_variant_set_type) + ZEND_FE(variant_cast, arginfo_variant_cast) + ZEND_FE(com_get_active_object, arginfo_com_get_active_object) + ZEND_FE(com_create_guid, arginfo_com_create_guid) + ZEND_FE(com_event_sink, arginfo_com_event_sink) + ZEND_FE(com_print_typeinfo, arginfo_com_print_typeinfo) + ZEND_FE(com_message_pump, arginfo_com_message_pump) + ZEND_FE(com_load_typelib, arginfo_com_load_typelib) + ZEND_FE_END +}; + + +static const zend_function_entry class_variant_methods[] = { + ZEND_ME(variant, __construct, arginfo_class_variant___construct, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + + +static const zend_function_entry class_com_methods[] = { + ZEND_ME(com, __construct, arginfo_class_com___construct, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + + +static const zend_function_entry class_dotnet_methods[] = { +#if HAVE_MSCOREE_H + ZEND_ME(dotnet, __construct, arginfo_class_dotnet___construct, ZEND_ACC_PUBLIC) +#endif + ZEND_FE_END +}; diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index 2a1740e01e..4ff80d96e9 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -27,7 +25,7 @@ #include "php_com_dotnet_internal.h" #include "Zend/zend_exceptions.h" -static zval *com_property_read(zval *object, zval *member, int type, void **cahce_slot, zval *rv) +static zval *com_property_read(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv) { php_com_dotnet_object *obj; VARIANT v; @@ -35,23 +33,22 @@ static zval *com_property_read(zval *object, zval *member, int type, void **cahc ZVAL_NULL(rv); - obj = CDNO_FETCH(object); + obj = (php_com_dotnet_object*) object; if (V_VT(&obj->v) == VT_DISPATCH) { - if (!try_convert_to_string(member)) { - return rv; - } - VariantInit(&v); - res = php_com_do_invoke(obj, Z_STRVAL_P(member), Z_STRLEN_P(member), + res = php_com_do_invoke(obj, ZSTR_VAL(member), ZSTR_LEN(member), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 0, NULL, 1); if (res == SUCCESS) { php_com_zval_from_variant(rv, &v, obj->code_page); VariantClear(&v); } else if (res == DISP_E_BADPARAMCOUNT) { - php_com_saproxy_create(object, rv, member); + zval zv; + + ZVAL_STR(&zv, member); + php_com_saproxy_create(object, rv, &zv); } } else { php_com_throw_exception(E_INVALIDARG, "this variant has no properties"); @@ -60,21 +57,17 @@ static zval *com_property_read(zval *object, zval *member, int type, void **cahc return rv; } -static zval *com_property_write(zval *object, zval *member, zval *value, void **cache_slot) +static zval *com_property_write(zend_object *object, zend_string *member, zval *value, void **cache_slot) { php_com_dotnet_object *obj; VARIANT v; - obj = CDNO_FETCH(object); + obj = (php_com_dotnet_object*) object; if (V_VT(&obj->v) == VT_DISPATCH) { - if (!try_convert_to_string(member)) { - return value; - } - VariantInit(&v); - if (SUCCESS == php_com_do_invoke(obj, Z_STRVAL_P(member), Z_STRLEN_P(member), + if (SUCCESS == php_com_do_invoke(obj, ZSTR_VAL(member), ZSTR_LEN(member), DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF, &v, 1, value, 0)) { VariantClear(&v); } @@ -84,14 +77,14 @@ static zval *com_property_write(zval *object, zval *member, zval *value, void ** return value; } -static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv) +static zval *com_read_dimension(zend_object *object, zval *offset, int type, zval *rv) { php_com_dotnet_object *obj; VARIANT v; ZVAL_NULL(rv); - obj = CDNO_FETCH(object); + obj = (php_com_dotnet_object*) object; if (V_VT(&obj->v) == VT_DISPATCH) { VariantInit(&v); @@ -120,14 +113,14 @@ static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv) return rv; } -static void com_write_dimension(zval *object, zval *offset, zval *value) +static void com_write_dimension(zend_object *object, zval *offset, zval *value) { php_com_dotnet_object *obj; zval args[2]; VARIANT v; HRESULT res; - obj = CDNO_FETCH(object); + obj = (php_com_dotnet_object*) object; if (offset == NULL) { php_com_throw_exception(DISP_E_BADINDEX, "appending to variants is not supported"); @@ -184,36 +177,20 @@ static void com_write_dimension(zval *object, zval *offset, zval *value) } } -static zval *com_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) +static zval *com_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot) { return NULL; } -#if 0 -static void com_object_set(zval **property, zval *value) -{ - /* Not yet implemented in the engine */ -} - -static zval *com_object_get(zval *property) -{ - /* Not yet implemented in the engine */ - return NULL; -} -#endif - -static int com_property_exists(zval *object, zval *member, int check_empty, void **cache_slot) +static int com_property_exists(zend_object *object, zend_string *member, int check_empty, void **cache_slot) { DISPID dispid; php_com_dotnet_object *obj; - obj = CDNO_FETCH(object); + obj = (php_com_dotnet_object*) object; if (V_VT(&obj->v) == VT_DISPATCH) { - if (!try_convert_to_string(member)) { - return 0; - } - if (SUCCEEDED(php_com_get_id_of_name(obj, Z_STRVAL_P(member), Z_STRLEN_P(member), &dispid))) { + if (SUCCEEDED(php_com_get_id_of_name(obj, ZSTR_VAL(member), ZSTR_LEN(member), &dispid))) { /* TODO: distinguish between property and method! */ return 1; } @@ -224,33 +201,33 @@ static int com_property_exists(zval *object, zval *member, int check_empty, void return 0; } -static int com_dimension_exists(zval *object, zval *member, int check_empty) +static int com_dimension_exists(zend_object *object, zval *member, int check_empty) { php_error_docref(NULL, E_WARNING, "Operation not yet supported on a COM object"); return 0; } -static void com_property_delete(zval *object, zval *member, void **cache_slot) +static void com_property_delete(zend_object *object, zend_string *member, void **cache_slot) { php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object"); } -static void com_dimension_delete(zval *object, zval *offset) +static void com_dimension_delete(zend_object *object, zval *offset) { php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object"); } -static HashTable *com_properties_get(zval *object) +static HashTable *com_properties_get(zend_object *object) { /* TODO: use type-info to get all the names and values ? * DANGER: if we do that, there is a strong possibility for * infinite recursion when the hash is displayed via var_dump(). * Perhaps it is best to leave it un-implemented. */ - return &zend_empty_array; + return (HashTable *) &zend_empty_array; } -static HashTable *com_get_gc(zval *object, zval **table, int *n) +static HashTable *com_get_gc(zend_object *object, zval **table, int *n) { *table = NULL; *n = 0; @@ -271,11 +248,42 @@ static void function_dtor(zval *zv) static PHP_FUNCTION(com_method_handler) { zval *object = getThis(); + zend_string *method = EX(func)->common.function_name; + zval *args = NULL; + php_com_dotnet_object *obj = CDNO_FETCH(object); + int nargs; + VARIANT v; + int ret = FAILURE; + + if (V_VT(&obj->v) != VT_DISPATCH) { + goto exit; + } + + nargs = ZEND_NUM_ARGS(); - Z_OBJ_HANDLER_P(object, call_method)( - ((zend_internal_function*)EX(func))->function_name, - Z_OBJ_P(object), - INTERNAL_FUNCTION_PARAM_PASSTHRU); + if (nargs) { + args = (zval *)safe_emalloc(sizeof(zval), nargs, 0); + zend_get_parameters_array_ex(nargs, args); + } + + VariantInit(&v); + + if (SUCCESS == php_com_do_invoke_byref(obj, (zend_internal_function*)EX(func), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, nargs, args)) { + php_com_zval_from_variant(return_value, &v, obj->code_page); + ret = SUCCESS; + VariantClear(&v); + } + + if (args) { + efree(args); + } + +exit: + /* Cleanup trampoline */ + ZEND_ASSERT(EX(func)->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE); + zend_string_release(EX(func)->common.function_name); + zend_free_trampoline(EX(func)); + EX(func) = NULL; } static zend_function *com_method_get(zend_object **object_ptr, zend_string *name, const zval *key) @@ -295,7 +303,8 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name /* check cache */ if (obj->method_cache == NULL || NULL == (fptr = zend_hash_find_ptr(obj->method_cache, name))) { - f.type = ZEND_OVERLOADED_FUNCTION; + memset(&f, 0, sizeof(zend_internal_function)); + f.type = ZEND_INTERNAL_FUNCTION; f.num_args = 0; f.arg_info = NULL; f.scope = obj->ce; @@ -325,10 +334,8 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name f.arg_info = ecalloc(bindptr.lpfuncdesc->cParams, sizeof(zend_arg_info)); for (i = 0; i < bindptr.lpfuncdesc->cParams; i++) { - f.arg_info[i].type = ZEND_TYPE_ENCODE(0,1); - if (bindptr.lpfuncdesc->lprgelemdescParam[i].paramdesc.wParamFlags & PARAMFLAG_FOUT) { - f.arg_info[i].pass_by_reference = ZEND_SEND_BY_REF; - } + zend_bool by_ref = (bindptr.lpfuncdesc->lprgelemdescParam[i].paramdesc.wParamFlags & PARAMFLAG_FOUT) != 0; + f.arg_info[i].type = (zend_type) ZEND_TYPE_INIT_NONE(_ZEND_ARG_INFO_FLAGS(by_ref, 0)); } f.num_args = bindptr.lpfuncdesc->cParams; @@ -370,6 +377,7 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name if (fptr) { /* duplicate this into a new chunk of emalloc'd memory, * since the engine will efree it */ + zend_string_addref(fptr->function_name); func = emalloc(sizeof(*fptr)); memcpy(func, fptr, sizeof(*fptr)); @@ -379,72 +387,6 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name return NULL; } -static int com_call_method(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS) -{ - zval *args = NULL; - php_com_dotnet_object *obj = (php_com_dotnet_object*)object; - int nargs; - VARIANT v; - int ret = FAILURE; - - if (V_VT(&obj->v) != VT_DISPATCH) { - return FAILURE; - } - - nargs = ZEND_NUM_ARGS(); - - if (nargs) { - args = (zval *)safe_emalloc(sizeof(zval), nargs, 0); - zend_get_parameters_array_ex(nargs, args); - } - - VariantInit(&v); - - if (SUCCESS == php_com_do_invoke_byref(obj, (zend_internal_function*)EX(func), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, nargs, args)) { - php_com_zval_from_variant(return_value, &v, obj->code_page); - ret = SUCCESS; - VariantClear(&v); - } - - if (args) { - efree(args); - } - - return ret; -} - -static zend_function *com_constructor_get(zend_object *object) -{ - php_com_dotnet_object *obj = (php_com_dotnet_object *) object; - static zend_internal_function c, d, v; - -#define POPULATE_CTOR(f, fn) \ - f.type = ZEND_INTERNAL_FUNCTION; \ - f.function_name = obj->ce->name; \ - f.scope = obj->ce; \ - f.arg_info = NULL; \ - f.num_args = 0; \ - f.fn_flags = 0; \ - f.handler = ZEND_FN(fn); \ - return (zend_function*)&f; - - switch (obj->ce->name->val[0]) { -#if HAVE_MSCOREE_H - case 'd': - POPULATE_CTOR(d, com_dotnet_create_instance); -#endif - - case 'c': - POPULATE_CTOR(c, com_create_instance); - - case 'v': - POPULATE_CTOR(v, com_variant_create_instance); - - default: - return NULL; - } -} - static zend_string* com_class_name_get(const zend_object *object) { php_com_dotnet_object *obj = (php_com_dotnet_object *)object; @@ -463,6 +405,8 @@ static int com_objects_compare(zval *object1, zval *object2) * So, we have this declaration here to fix it */ STDAPI VarCmp(LPVARIANT pvarLeft, LPVARIANT pvarRight, LCID lcid, DWORD flags); + ZEND_COMPARE_OBJECTS_FALLBACK(object1, object2); + obja = CDNO_FETCH(object1); objb = CDNO_FETCH(object2); @@ -485,14 +429,14 @@ static int com_objects_compare(zval *object1, zval *object2) return ret; } -static int com_object_cast(zval *readobj, zval *writeobj, int type) +static int com_object_cast(zend_object *readobj, zval *writeobj, int type) { php_com_dotnet_object *obj; VARIANT v; VARTYPE vt = VT_EMPTY; HRESULT res = S_OK; - obj = CDNO_FETCH(readobj); + obj = (php_com_dotnet_object*) readobj; ZVAL_NULL(writeobj); VariantInit(&v); @@ -542,12 +486,12 @@ static int com_object_cast(zval *readobj, zval *writeobj, int type) return zend_std_cast_object_tostring(readobj, writeobj, type); } -static int com_object_count(zval *object, zend_long *count) +static int com_object_count(zend_object *object, zend_long *count) { php_com_dotnet_object *obj; LONG ubound = 0, lbound = 0; - obj = CDNO_FETCH(object); + obj = (php_com_dotnet_object*) object; if (!V_ISARRAY(&obj->v)) { return FAILURE; @@ -571,23 +515,22 @@ zend_object_handlers php_com_object_handlers = { com_read_dimension, com_write_dimension, com_get_property_ptr_ptr, - NULL, /* com_object_get, */ - NULL, /* com_object_set, */ com_property_exists, com_property_delete, com_dimension_exists, com_dimension_delete, com_properties_get, com_method_get, - com_call_method, - com_constructor_get, + zend_std_get_constructor, com_class_name_get, - com_objects_compare, com_object_cast, com_object_count, NULL, /* get_debug_info */ NULL, /* get_closure */ com_get_gc, /* get_gc */ + NULL, /* do_operation */ + com_objects_compare, /* compare */ + NULL, /* get_properties_for */ }; void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable) @@ -643,11 +586,11 @@ void php_com_object_free_storage(zend_object *object) zend_object_std_dtor(object); } -zend_object* php_com_object_clone(zval *object) +zend_object* php_com_object_clone(zend_object *object) { php_com_dotnet_object *cloneobj, *origobject; - origobject = (php_com_dotnet_object*)Z_OBJ_P(object); + origobject = (php_com_dotnet_object*) object; cloneobj = (php_com_dotnet_object*)emalloc(sizeof(php_com_dotnet_object)); memcpy(cloneobj, origobject, sizeof(*cloneobj)); diff --git a/ext/com_dotnet/com_iterator.c b/ext/com_dotnet/com_iterator.c index c3206497cf..6126e958d5 100644 --- a/ext/com_dotnet/com_iterator.c +++ b/ext/com_dotnet/com_iterator.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -129,7 +127,8 @@ static const zend_object_iterator_funcs com_iter_funcs = { com_iter_get_data, com_iter_get_key, com_iter_move_forwards, - NULL + NULL, + NULL, /* get_gc */ }; zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int by_ref) @@ -150,7 +149,7 @@ zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int b obj = CDNO_FETCH(object); if (V_VT(&obj->v) != VT_DISPATCH && !V_ISARRAY(&obj->v)) { - php_error_docref(NULL, E_WARNING, "variant is not an object or array VT=%d", V_VT(&obj->v)); + php_error_docref(NULL, E_WARNING, "Variant is not an object or array VT=%d", V_VT(&obj->v)); return NULL; } diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c index 13a94033e6..24230761c1 100644 --- a/ext/com_dotnet/com_misc.c +++ b/ext/com_dotnet/com_misc.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | diff --git a/ext/com_dotnet/com_olechar.c b/ext/com_dotnet/com_olechar.c index ea9cf1154c..89aed1e389 100644 --- a/ext/com_dotnet/com_olechar.c +++ b/ext/com_dotnet/com_olechar.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -28,7 +26,7 @@ #include "php_com_dotnet_internal.h" -PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, size_t string_len, int codepage) +PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(const char *string, size_t string_len, int codepage) { OLECHAR *olestring = NULL; DWORD flags = codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS; diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c index 3283e59df7..3bde7175d8 100644 --- a/ext/com_dotnet/com_persist.c +++ b/ext/com_dotnet/com_persist.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -31,6 +29,7 @@ #include "php_com_dotnet.h" #include "php_com_dotnet_internal.h" #include "Zend/zend_exceptions.h" +#include "com_persist_arginfo.h" /* {{{ expose php_stream as a COM IStream */ @@ -277,13 +276,11 @@ PHP_COM_DOTNET_API IStream *php_com_wrapper_export_stream(php_stream *stream) return (IStream*)stm; } -#define CPH_ME(fname, arginfo) PHP_ME(com_persist, fname, arginfo, ZEND_ACC_PUBLIC) -#define CPH_SME(fname, arginfo) PHP_ME(com_persist, fname, arginfo, ZEND_ACC_ALLOW_STATIC|ZEND_ACC_PUBLIC) -#define CPH_METHOD(fname) static PHP_METHOD(com_persist, fname) +#define CPH_METHOD(fname) PHP_METHOD(COMPersistHelper, fname) #define CPH_FETCH() php_com_persist_helper *helper = (php_com_persist_helper*)Z_OBJ_P(getThis()); -#define CPH_NO_OBJ() if (helper->unk == NULL) { php_com_throw_exception(E_INVALIDARG, "No COM object is associated with this helper instance"); return; } +#define CPH_NO_OBJ() if (helper->unk == NULL) { php_com_throw_exception(E_INVALIDARG, "No COM object is associated with this helper instance"); RETURN_THROWS(); } typedef struct { zend_object std; @@ -322,14 +319,17 @@ static inline HRESULT get_persist_file(php_com_persist_helper *helper) } -/* {{{ proto string COMPersistHelper::GetCurFile() - Determines the filename into which an object will be saved, or false if none is set, via IPersistFile::GetCurFile */ +/* {{{ Determines the filename into which an object will be saved, or false if none is set, via IPersistFile::GetCurFile */ CPH_METHOD(GetCurFileName) { HRESULT res; OLECHAR *olename = NULL; CPH_FETCH(); + if (zend_parse_parameters_none() == FAILURE) { + RETURN_THROWS(); + } + CPH_NO_OBJ(); res = get_persist_file(helper); @@ -357,8 +357,7 @@ CPH_METHOD(GetCurFileName) /* }}} */ -/* {{{ proto bool COMPersistHelper::SaveToFile(string filename [, bool remember]) - Persist object data to file, via IPersistFile::Save */ +/* {{{ Persist object data to file, via IPersistFile::Save */ CPH_METHOD(SaveToFile) { HRESULT res; @@ -368,16 +367,15 @@ CPH_METHOD(SaveToFile) OLECHAR *olefilename = NULL; CPH_FETCH(); + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p!|b", + &filename, &filename_len, &remember)) { + RETURN_THROWS(); + } + CPH_NO_OBJ(); res = get_persist_file(helper); if (helper->ipf) { - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p!|b", - &filename, &filename_len, &remember)) { - php_com_throw_exception(E_INVALIDARG, "Invalid arguments"); - return; - } - if (filename) { fullpath = expand_filepath(filename, NULL); if (!fullpath) { @@ -420,8 +418,7 @@ CPH_METHOD(SaveToFile) } /* }}} */ -/* {{{ proto bool COMPersistHelper::LoadFromFile(string filename [, int flags]) - Load object data from file, via IPersistFile::Load */ +/* {{{ Load object data from file, via IPersistFile::Load */ CPH_METHOD(LoadFromFile) { HRESULT res; @@ -431,17 +428,15 @@ CPH_METHOD(LoadFromFile) OLECHAR *olefilename; CPH_FETCH(); + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p|l", + &filename, &filename_len, &flags)) { + RETURN_THROWS(); + } + CPH_NO_OBJ(); res = get_persist_file(helper); if (helper->ipf) { - - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p|l", - &filename, &filename_len, &flags)) { - php_com_throw_exception(E_INVALIDARG, "Invalid arguments"); - return; - } - if (!(fullpath = expand_filepath(filename, NULL))) { RETURN_FALSE; } @@ -467,14 +462,17 @@ CPH_METHOD(LoadFromFile) } /* }}} */ -/* {{{ proto int COMPersistHelper::GetMaxStreamSize() - Gets maximum stream size required to store the object data, via IPersistStream::GetSizeMax (or IPersistStreamInit::GetSizeMax) */ +/* {{{ Gets maximum stream size required to store the object data, via IPersistStream::GetSizeMax (or IPersistStreamInit::GetSizeMax) */ CPH_METHOD(GetMaxStreamSize) { HRESULT res; ULARGE_INTEGER size; CPH_FETCH(); + if (zend_parse_parameters_none() == FAILURE) { + RETURN_THROWS(); + } + CPH_NO_OBJ(); res = get_persist_stream_init(helper); @@ -486,7 +484,7 @@ CPH_METHOD(GetMaxStreamSize) res = IPersistStream_GetSizeMax(helper->ips, &size); } else { php_com_throw_exception(res, NULL); - return; + RETURN_THROWS(); } } @@ -499,13 +497,16 @@ CPH_METHOD(GetMaxStreamSize) } /* }}} */ -/* {{{ proto int COMPersistHelper::InitNew() - Initializes the object to a default state, via IPersistStreamInit::InitNew */ +/* {{{ Initializes the object to a default state, via IPersistStreamInit::InitNew */ CPH_METHOD(InitNew) { HRESULT res; CPH_FETCH(); + if (zend_parse_parameters_none() == FAILURE) { + RETURN_THROWS(); + } + CPH_NO_OBJ(); res = get_persist_stream_init(helper); @@ -523,8 +524,7 @@ CPH_METHOD(InitNew) } /* }}} */ -/* {{{ proto mixed COMPersistHelper::LoadFromStream(resource stream) - Initializes an object from the stream where it was previously saved, via IPersistStream::Load or OleLoadFromStream */ +/* {{{ Initializes an object from the stream where it was previously saved, via IPersistStream::Load or OleLoadFromStream */ CPH_METHOD(LoadFromStream) { zval *zstm; @@ -534,21 +534,20 @@ CPH_METHOD(LoadFromStream) CPH_FETCH(); if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zstm)) { - php_com_throw_exception(E_INVALIDARG, "invalid arguments"); - return; + RETURN_THROWS(); } php_stream_from_zval_no_verify(stream, zstm); if (stream == NULL) { php_com_throw_exception(E_INVALIDARG, "expected a stream"); - return; + RETURN_THROWS(); } stm = php_com_wrapper_export_stream(stream); if (stm == NULL) { php_com_throw_exception(E_UNEXPECTED, "failed to wrap stream"); - return; + RETURN_THROWS(); } res = S_OK; @@ -578,13 +577,12 @@ CPH_METHOD(LoadFromStream) if (FAILED(res)) { php_com_throw_exception(res, NULL); - RETURN_NULL(); + RETURN_THROWS(); } } /* }}} */ -/* {{{ proto int COMPersistHelper::SaveToStream(resource stream) - Saves the object to a stream, via IPersistStream::Save */ +/* {{{ Saves the object to a stream, via IPersistStream::Save */ CPH_METHOD(SaveToStream) { zval *zstm; @@ -596,21 +594,20 @@ CPH_METHOD(SaveToStream) CPH_NO_OBJ(); if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zstm)) { - php_com_throw_exception(E_INVALIDARG, "invalid arguments"); - return; + RETURN_THROWS(); } php_stream_from_zval_no_verify(stream, zstm); if (stream == NULL) { php_com_throw_exception(E_INVALIDARG, "expected a stream"); - return; + RETURN_THROWS(); } stm = php_com_wrapper_export_stream(stream); if (stm == NULL) { php_com_throw_exception(E_UNEXPECTED, "failed to wrap stream"); - return; + RETURN_THROWS(); } res = get_persist_stream_init(helper); @@ -627,15 +624,14 @@ CPH_METHOD(SaveToStream) if (FAILED(res)) { php_com_throw_exception(res, NULL); - return; + RETURN_THROWS(); } RETURN_TRUE; } /* }}} */ -/* {{{ proto COMPersistHelper::__construct([object com_object]) - Creates a persistence helper object, usually associated with a com_object */ +/* {{{ Creates a persistence helper object, usually associated with a com_object */ CPH_METHOD(__construct) { php_com_dotnet_object *obj = NULL; @@ -644,8 +640,7 @@ CPH_METHOD(__construct) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &zobj, php_com_variant_class_entry)) { - php_com_throw_exception(E_INVALIDARG, "invalid arguments"); - return; + RETURN_THROWS(); } if (!zobj) { @@ -656,7 +651,7 @@ CPH_METHOD(__construct) if (V_VT(&obj->v) != VT_DISPATCH || V_DISPATCH(&obj->v) == NULL) { php_com_throw_exception(E_INVALIDARG, "parameter must represent an IDispatch COM object"); - return; + RETURN_THROWS(); } /* it is always safe to cast an interface to IUnknown */ @@ -667,20 +662,6 @@ CPH_METHOD(__construct) /* }}} */ - - -static const zend_function_entry com_persist_helper_methods[] = { - CPH_ME(__construct, NULL) - CPH_ME(GetCurFileName, NULL) - CPH_ME(SaveToFile, NULL) - CPH_ME(LoadFromFile, NULL) - CPH_ME(GetMaxStreamSize, NULL) - CPH_ME(InitNew, NULL) - CPH_ME(LoadFromStream, NULL) - CPH_ME(SaveToStream, NULL) - PHP_FE_END -}; - static void helper_free_storage(zend_object *obj) { php_com_persist_helper *object = (php_com_persist_helper*)obj; @@ -701,9 +682,9 @@ static void helper_free_storage(zend_object *obj) } -static zend_object* helper_clone(zval *obj) +static zend_object* helper_clone(zend_object *obj) { - php_com_persist_helper *clone, *object = (php_com_persist_helper*)Z_OBJ_P(obj); + php_com_persist_helper *clone, *object = (php_com_persist_helper*) obj; clone = emalloc(sizeof(*object)); memcpy(clone, object, sizeof(*object)); @@ -746,7 +727,7 @@ int php_com_persist_minit(INIT_FUNC_ARGS) helper_handlers.free_obj = helper_free_storage; helper_handlers.clone_obj = helper_clone; - INIT_CLASS_ENTRY(ce, "COMPersistHelper", com_persist_helper_methods); + INIT_CLASS_ENTRY(ce, "COMPersistHelper", class_COMPersistHelper_methods); ce.create_object = helper_new; helper_ce = zend_register_internal_class(&ce); helper_ce->ce_flags |= ZEND_ACC_FINAL; diff --git a/ext/com_dotnet/com_persist.stub.php b/ext/com_dotnet/com_persist.stub.php new file mode 100644 index 0000000000..09a842d8fb --- /dev/null +++ b/ext/com_dotnet/com_persist.stub.php @@ -0,0 +1,24 @@ +<?php + +/** @generate-function-entries */ + +final class COMPersistHelper +{ + public function __construct(?VARIANT $com_object) {} + + public function GetCurFileName(): string|false {} + + public function SaveToFile(?string $filename, bool $remember = true): bool {} + + public function LoadFromFile(string $path, int $flags = 0): bool {} + + public function GetMaxStreamSize(): int {} + + public function InitNew(): bool {} + + /** @param resource $stream */ + public function LoadFromStream($stream): bool {} + + /** @param resource $stream */ + public function SaveToStream($stream): bool {} +} diff --git a/ext/com_dotnet/com_persist_arginfo.h b/ext/com_dotnet/com_persist_arginfo.h new file mode 100644 index 0000000000..0665dc343b --- /dev/null +++ b/ext/com_dotnet/com_persist_arginfo.h @@ -0,0 +1,54 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 47d926b2ba30bb3616f4175664723352fff164e7 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_COMPersistHelper___construct, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, com_object, VARIANT, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_COMPersistHelper_GetCurFileName, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_SaveToFile, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 1) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, remember, _IS_BOOL, 0, "true") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_LoadFromFile, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_GetMaxStreamSize, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_InitNew, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_LoadFromStream, 0, 1, _IS_BOOL, 0) + ZEND_ARG_INFO(0, stream) +ZEND_END_ARG_INFO() + +#define arginfo_class_COMPersistHelper_SaveToStream arginfo_class_COMPersistHelper_LoadFromStream + + +ZEND_METHOD(COMPersistHelper, __construct); +ZEND_METHOD(COMPersistHelper, GetCurFileName); +ZEND_METHOD(COMPersistHelper, SaveToFile); +ZEND_METHOD(COMPersistHelper, LoadFromFile); +ZEND_METHOD(COMPersistHelper, GetMaxStreamSize); +ZEND_METHOD(COMPersistHelper, InitNew); +ZEND_METHOD(COMPersistHelper, LoadFromStream); +ZEND_METHOD(COMPersistHelper, SaveToStream); + + +static const zend_function_entry class_COMPersistHelper_methods[] = { + ZEND_ME(COMPersistHelper, __construct, arginfo_class_COMPersistHelper___construct, ZEND_ACC_PUBLIC) + ZEND_ME(COMPersistHelper, GetCurFileName, arginfo_class_COMPersistHelper_GetCurFileName, ZEND_ACC_PUBLIC) + ZEND_ME(COMPersistHelper, SaveToFile, arginfo_class_COMPersistHelper_SaveToFile, ZEND_ACC_PUBLIC) + ZEND_ME(COMPersistHelper, LoadFromFile, arginfo_class_COMPersistHelper_LoadFromFile, ZEND_ACC_PUBLIC) + ZEND_ME(COMPersistHelper, GetMaxStreamSize, arginfo_class_COMPersistHelper_GetMaxStreamSize, ZEND_ACC_PUBLIC) + ZEND_ME(COMPersistHelper, InitNew, arginfo_class_COMPersistHelper_InitNew, ZEND_ACC_PUBLIC) + ZEND_ME(COMPersistHelper, LoadFromStream, arginfo_class_COMPersistHelper_LoadFromStream, ZEND_ACC_PUBLIC) + ZEND_ME(COMPersistHelper, SaveToStream, arginfo_class_COMPersistHelper_SaveToStream, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c index eec6e2998e..56f7fc6846 100644 --- a/ext/com_dotnet/com_saproxy.c +++ b/ext/com_dotnet/com_saproxy.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -37,7 +35,6 @@ typedef struct { zend_object std; /* the object we a proxying for; we hold a refcount to it */ - zval *zobj; php_com_dotnet_object *obj; /* how many dimensions we are indirecting to get into this element */ @@ -69,7 +66,7 @@ static inline void clone_indices(php_com_saproxy *dest, php_com_saproxy *src, in } } -static zval *saproxy_property_read(zval *object, zval *member, int type, void **cache_slot, zval *rv) +static zval *saproxy_property_read(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv) { ZVAL_NULL(rv); @@ -78,15 +75,15 @@ static zval *saproxy_property_read(zval *object, zval *member, int type, void ** return rv; } -static zval *saproxy_property_write(zval *object, zval *member, zval *value, void **cache_slot) +static zval *saproxy_property_write(zend_object *object, zend_string *member, zval *value, void **cache_slot) { php_com_throw_exception(E_INVALIDARG, "safearray has no properties"); return value; } -static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *rv) +static zval *saproxy_read_dimension(zend_object *object, zval *offset, int type, zval *rv) { - php_com_saproxy *proxy = SA_FETCH(object); + php_com_saproxy *proxy = (php_com_saproxy*) object; UINT dims, i; SAFEARRAY *sa; LONG ubound, lbound; @@ -207,9 +204,9 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval * return rv; } -static void saproxy_write_dimension(zval *object, zval *offset, zval *value) +static void saproxy_write_dimension(zend_object *object, zval *offset, zval *value) { - php_com_saproxy *proxy = SA_FETCH(object); + php_com_saproxy *proxy = (php_com_saproxy*) object; UINT dims, i; HRESULT res; VARIANT v; @@ -283,41 +280,29 @@ static void saproxy_write_dimension(zval *object, zval *offset, zval *value) } } -#if 0 -static void saproxy_object_set(zval **property, zval *value) -{ -} - -static zval *saproxy_object_get(zval *property) -{ - /* Not yet implemented in the engine */ - return NULL; -} -#endif - -static int saproxy_property_exists(zval *object, zval *member, int check_empty, void **cache_slot) +static int saproxy_property_exists(zend_object *object, zend_string *member, int check_empty, void **cache_slot) { /* no properties */ return 0; } -static int saproxy_dimension_exists(zval *object, zval *member, int check_empty) +static int saproxy_dimension_exists(zend_object *object, zval *member, int check_empty) { php_error_docref(NULL, E_WARNING, "Operation not yet supported on a COM object"); return 0; } -static void saproxy_property_delete(zval *object, zval *member, void **cache_slot) +static void saproxy_property_delete(zend_object *object, zend_string *member, void **cache_slot) { php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object"); } -static void saproxy_dimension_delete(zval *object, zval *offset) +static void saproxy_dimension_delete(zend_object *object, zval *offset) { php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object"); } -static HashTable *saproxy_properties_get(zval *object) +static HashTable *saproxy_properties_get(zend_object *object) { /* no properties */ return NULL; @@ -329,11 +314,6 @@ static zend_function *saproxy_method_get(zend_object **object, zend_string *name return NULL; } -static int saproxy_call_method(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS) -{ - return FAILURE; -} - static zend_function *saproxy_constructor_get(zend_object *object) { /* user cannot instantiate */ @@ -347,17 +327,18 @@ static zend_string* saproxy_class_name_get(const zend_object *object) static int saproxy_objects_compare(zval *object1, zval *object2) { + ZEND_COMPARE_OBJECTS_FALLBACK(object1, object2); return -1; } -static int saproxy_object_cast(zval *readobj, zval *writeobj, int type) +static int saproxy_object_cast(zend_object *readobj, zval *writeobj, int type) { return FAILURE; } -static int saproxy_count_elements(zval *object, zend_long *count) +static int saproxy_count_elements(zend_object *object, zend_long *count) { - php_com_saproxy *proxy = SA_FETCH(object); + php_com_saproxy *proxy = (php_com_saproxy*) object; LONG ubound, lbound; if (!V_ISARRAY(&proxy->obj->v)) { @@ -383,21 +364,22 @@ static void saproxy_free_storage(zend_object *object) //??? } //??? } + OBJ_RELEASE(&proxy->obj->zo); + zend_object_std_dtor(object); - zval_ptr_dtor(proxy->zobj); efree(proxy->indices); } -static zend_object* saproxy_clone(zval *object) +static zend_object* saproxy_clone(zend_object *object) { - php_com_saproxy *proxy = (php_com_saproxy *)Z_OBJ_P(object); + php_com_saproxy *proxy = (php_com_saproxy *) object; php_com_saproxy *cloneproxy; cloneproxy = emalloc(sizeof(*cloneproxy)); memcpy(cloneproxy, proxy, sizeof(*cloneproxy)); - Z_ADDREF_P(cloneproxy->zobj); + GC_ADDREF(&cloneproxy->obj->zo); cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval), 0); clone_indices(cloneproxy, proxy, proxy->dimensions); @@ -414,40 +396,40 @@ zend_object_handlers php_com_saproxy_handlers = { saproxy_read_dimension, saproxy_write_dimension, NULL, - NULL, /* saproxy_object_get, */ - NULL, /* saproxy_object_set, */ saproxy_property_exists, saproxy_property_delete, saproxy_dimension_exists, saproxy_dimension_delete, saproxy_properties_get, saproxy_method_get, - saproxy_call_method, saproxy_constructor_get, saproxy_class_name_get, - saproxy_objects_compare, saproxy_object_cast, - saproxy_count_elements + saproxy_count_elements, + NULL, /* get_debug_info */ + NULL, /* get_closure */ + NULL, /* get_gc */ + NULL, /* do_operation */ + saproxy_objects_compare, /* compare */ + NULL, /* get_properties_for */ }; -int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index) +int php_com_saproxy_create(zend_object *com_object, zval *proxy_out, zval *index) { php_com_saproxy *proxy, *rel = NULL; proxy = ecalloc(1, sizeof(*proxy)); proxy->dimensions = 1; - if (Z_OBJCE_P(com_object) == php_com_saproxy_class_entry) { - rel = SA_FETCH(com_object); + if (com_object->ce == php_com_saproxy_class_entry) { + rel = (php_com_saproxy*) com_object; proxy->obj = rel->obj; - proxy->zobj = rel->zobj; proxy->dimensions += rel->dimensions; } else { - proxy->obj = CDNO_FETCH(com_object); - proxy->zobj = com_object; + proxy->obj = (php_com_dotnet_object*) com_object; } - Z_ADDREF_P(proxy->zobj); + GC_ADDREF(&proxy->obj->zo); proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval), 0); if (rel) { @@ -538,7 +520,8 @@ static const zend_object_iterator_funcs saproxy_iter_funcs = { saproxy_iter_get_data, saproxy_iter_get_key, saproxy_iter_move_forwards, - NULL + NULL, + NULL, /* get_gc */ }; diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c index 4ee73cf41f..4112b0ce06 100644 --- a/ext/com_dotnet/com_typeinfo.c +++ b/ext/com_dotnet/com_typeinfo.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -262,8 +260,7 @@ ITypeLib *php_com_cache_typelib(ITypeLib* TL, char *cache_key, zend_long cache_k return result; } -PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string, - int codepage, int *cached) +PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(const char *search_string, int codepage) { ITypeLib *TL; char *name_dup; @@ -274,14 +271,12 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string, #endif if ((TL = zend_hash_find_ptr(&php_com_typelibraries, key)) != NULL) { - *cached = 1; /* add a reference for the caller */ ITypeLib_AddRef(TL); goto php_com_load_typelib_via_cache_return; } - *cached = 0; name_dup = estrndup(ZSTR_VAL(key), ZSTR_LEN(key)); TL = php_com_load_typelib(name_dup, codepage); efree(name_dup); diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c index dc4e42ddc5..949f3ca1dd 100644 --- a/ext/com_dotnet/com_variant.c +++ b/ext/com_dotnet/com_variant.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -416,14 +414,14 @@ PHP_COM_DOTNET_API int php_com_copy_variant(VARIANT *dstvar, VARIANT *srcvar) return php_com_copy_variant(V_VARIANTREF(dstvar), srcvar); default: - php_error_docref(NULL, E_WARNING, "variant->variant: failed to copy from 0x%x to 0x%x", V_VT(dstvar), V_VT(srcvar)); + php_error_docref(NULL, E_WARNING, "variant->__construct: failed to copy from 0x%x to 0x%x", V_VT(dstvar), V_VT(srcvar)); ret = FAILURE; } return ret; } /* {{{ com_variant_create_instance - ctor for new VARIANT() */ -PHP_FUNCTION(com_variant_create_instance) +PHP_METHOD(variant, __construct) { /* VARTYPE == unsigned short */ zend_long vt = VT_EMPTY; zend_long codepage = CP_ACP; @@ -437,15 +435,14 @@ PHP_FUNCTION(com_variant_create_instance) return; } - obj = CDNO_FETCH(object); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "z!|ll", &zvalue, &vt, &codepage)) { - php_com_throw_exception(E_INVALIDARG, "Invalid arguments"); - return; + RETURN_THROWS(); } php_com_initialize(); + obj = CDNO_FETCH(object); + if (ZEND_NUM_ARGS() == 3) { obj->code_page = (int)codepage; } @@ -494,8 +491,7 @@ PHP_FUNCTION(com_variant_create_instance) } /* }}} */ -/* {{{ proto void variant_set(object variant, mixed value) - Assigns a new value for a variant object */ +/* {{{ Assigns a new value for a variant object */ PHP_FUNCTION(variant_set) { zval *zobj, *zvalue = NULL; @@ -503,7 +499,7 @@ PHP_FUNCTION(variant_set) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oz!", &zobj, php_com_variant_class_entry, &zvalue)) { - return; + RETURN_THROWS(); } obj = CDNO_FETCH(zobj); @@ -581,7 +577,7 @@ static void variant_binary_operation(enum variant_binary_opcode op, INTERNAL_FUN php_com_variant_from_zval(vright, zright, codepage); } else { - return; + RETURN_THROWS(); } switch (op) { @@ -641,104 +637,91 @@ static void variant_binary_operation(enum variant_binary_opcode op, INTERNAL_FUN } /* }}} */ -/* {{{ proto mixed variant_add(mixed left, mixed right) - "Adds" two variant values together and returns the result */ +/* {{{ "Adds" two variant values together and returns the result */ PHP_FUNCTION(variant_add) { variant_binary_operation(VOP_ADD, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_cat(mixed left, mixed right) - concatenates two variant values together and returns the result */ +/* {{{ concatenates two variant values together and returns the result */ PHP_FUNCTION(variant_cat) { variant_binary_operation(VOP_CAT, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_sub(mixed left, mixed right) - subtracts the value of the right variant from the left variant value and returns the result */ +/* {{{ subtracts the value of the right variant from the left variant value and returns the result */ PHP_FUNCTION(variant_sub) { variant_binary_operation(VOP_SUB, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_mul(mixed left, mixed right) - multiplies the values of the two variants and returns the result */ +/* {{{ multiplies the values of the two variants and returns the result */ PHP_FUNCTION(variant_mul) { variant_binary_operation(VOP_MUL, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_and(mixed left, mixed right) - performs a bitwise AND operation between two variants and returns the result */ +/* {{{ performs a bitwise AND operation between two variants and returns the result */ PHP_FUNCTION(variant_and) { variant_binary_operation(VOP_AND, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_div(mixed left, mixed right) - Returns the result from dividing two variants */ +/* {{{ Returns the result from dividing two variants */ PHP_FUNCTION(variant_div) { variant_binary_operation(VOP_DIV, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_eqv(mixed left, mixed right) - Performs a bitwise equivalence on two variants */ +/* {{{ Performs a bitwise equivalence on two variants */ PHP_FUNCTION(variant_eqv) { variant_binary_operation(VOP_EQV, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_idiv(mixed left, mixed right) - Converts variants to integers and then returns the result from dividing them */ +/* {{{ Converts variants to integers and then returns the result from dividing them */ PHP_FUNCTION(variant_idiv) { variant_binary_operation(VOP_IDIV, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_imp(mixed left, mixed right) - Performs a bitwise implication on two variants */ +/* {{{ Performs a bitwise implication on two variants */ PHP_FUNCTION(variant_imp) { variant_binary_operation(VOP_IMP, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_mod(mixed left, mixed right) - Divides two variants and returns only the remainder */ +/* {{{ Divides two variants and returns only the remainder */ PHP_FUNCTION(variant_mod) { variant_binary_operation(VOP_MOD, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_or(mixed left, mixed right) - Performs a logical disjunction on two variants */ +/* {{{ Performs a logical disjunction on two variants */ PHP_FUNCTION(variant_or) { variant_binary_operation(VOP_OR, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_pow(mixed left, mixed right) - Returns the result of performing the power function with two variants */ +/* {{{ Returns the result of performing the power function with two variants */ PHP_FUNCTION(variant_pow) { variant_binary_operation(VOP_POW, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_xor(mixed left, mixed right) - Performs a logical exclusion on two variants */ +/* {{{ Performs a logical exclusion on two variants */ PHP_FUNCTION(variant_xor) { variant_binary_operation(VOP_XOR, INTERNAL_FUNCTION_PARAM_PASSTHRU); @@ -767,7 +750,7 @@ static void variant_unary_operation(enum variant_unary_opcode op, INTERNAL_FUNCT vleft = &left_val; php_com_variant_from_zval(vleft, zleft, codepage); } else { - return; + RETURN_THROWS(); } switch (op) { @@ -801,48 +784,42 @@ static void variant_unary_operation(enum variant_unary_opcode op, INTERNAL_FUNCT } /* }}} */ -/* {{{ proto mixed variant_abs(mixed left) - Returns the absolute value of a variant */ +/* {{{ Returns the absolute value of a variant */ PHP_FUNCTION(variant_abs) { variant_unary_operation(VOP_ABS, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_fix(mixed left) - Returns the integer part ? of a variant */ +/* {{{ Returns the integer part ? of a variant */ PHP_FUNCTION(variant_fix) { variant_unary_operation(VOP_FIX, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_int(mixed left) - Returns the integer portion of a variant */ +/* {{{ Returns the integer portion of a variant */ PHP_FUNCTION(variant_int) { variant_unary_operation(VOP_INT, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_neg(mixed left) - Performs logical negation on a variant */ +/* {{{ Performs logical negation on a variant */ PHP_FUNCTION(variant_neg) { variant_unary_operation(VOP_NEG, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_not(mixed left) - Performs bitwise not negation on a variant */ +/* {{{ Performs bitwise not negation on a variant */ PHP_FUNCTION(variant_not) { variant_unary_operation(VOP_NOT, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ -/* {{{ proto mixed variant_round(mixed left, int decimals) - Rounds a variant to the specified number of decimal places */ +/* {{{ Rounds a variant to the specified number of decimal places */ PHP_FUNCTION(variant_round) { VARIANT vres; @@ -865,7 +842,7 @@ PHP_FUNCTION(variant_round) vleft = &left_val; php_com_variant_from_zval(vleft, zleft, codepage); } else { - return; + RETURN_THROWS(); } if (SUCCEEDED(VarRound(vleft, (int)decimals, &vres))) { @@ -877,8 +854,7 @@ PHP_FUNCTION(variant_round) } /* }}} */ -/* {{{ proto int variant_cmp(mixed left, mixed right [, int lcid [, int flags]]) - Compares two variants */ +/* {{{ Compares two variants */ PHP_FUNCTION(variant_cmp) { VARIANT left_val, right_val; @@ -925,7 +901,7 @@ PHP_FUNCTION(variant_cmp) php_com_variant_from_zval(vright, zright, codepage); } else { - return; + RETURN_THROWS(); } ZVAL_LONG(return_value, VarCmp(vleft, vright, (LCID)lcid, (ULONG)flags)); @@ -935,8 +911,7 @@ PHP_FUNCTION(variant_cmp) } /* }}} */ -/* {{{ proto int variant_date_to_timestamp(object variant) - Converts a variant date/time value to unix timestamp */ +/* {{{ Converts a variant date/time value to unix timestamp */ PHP_FUNCTION(variant_date_to_timestamp) { VARIANT vres; @@ -947,7 +922,7 @@ PHP_FUNCTION(variant_date_to_timestamp) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zleft, php_com_variant_class_entry)) { - return; + RETURN_THROWS(); } obj = CDNO_FETCH(zleft); @@ -974,8 +949,7 @@ PHP_FUNCTION(variant_date_to_timestamp) } /* }}} */ -/* {{{ proto object variant_date_from_timestamp(int timestamp) - Returns a variant date representation of a unix timestamp */ +/* {{{ Returns a variant date representation of a unix timestamp */ PHP_FUNCTION(variant_date_from_timestamp) { zend_long timestamp; @@ -986,7 +960,7 @@ PHP_FUNCTION(variant_date_from_timestamp) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", ×tamp)) { - return; + RETURN_THROWS(); } if (timestamp < 0) { @@ -1023,8 +997,7 @@ PHP_FUNCTION(variant_date_from_timestamp) } /* }}} */ -/* {{{ proto int variant_get_type(object variant) - Returns the VT_XXX type code for a variant */ +/* {{{ Returns the VT_XXX type code for a variant */ PHP_FUNCTION(variant_get_type) { zval *zobj; @@ -1032,7 +1005,7 @@ PHP_FUNCTION(variant_get_type) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zobj, php_com_variant_class_entry)) { - return; + RETURN_THROWS(); } obj = CDNO_FETCH(zobj); @@ -1040,8 +1013,7 @@ PHP_FUNCTION(variant_get_type) } /* }}} */ -/* {{{ proto void variant_set_type(object variant, int type) - Convert a variant into another type. Variant is modified "in-place" */ +/* {{{ Convert a variant into another type. Variant is modified "in-place" */ PHP_FUNCTION(variant_set_type) { zval *zobj; @@ -1051,7 +1023,7 @@ PHP_FUNCTION(variant_set_type) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &zobj, php_com_variant_class_entry, &vt)) { - return; + RETURN_THROWS(); } obj = CDNO_FETCH(zobj); @@ -1075,8 +1047,7 @@ PHP_FUNCTION(variant_set_type) } /* }}} */ -/* {{{ proto object variant_cast(object variant, int type) - Convert a variant into a new variant object of another type */ +/* {{{ Convert a variant into a new variant object of another type */ PHP_FUNCTION(variant_cast) { zval *zobj; @@ -1087,7 +1058,7 @@ PHP_FUNCTION(variant_cast) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &zobj, php_com_variant_class_entry, &vt)) { - return; + RETURN_THROWS(); } obj = CDNO_FETCH(zobj); diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c index 78d8912a90..6683c3968b 100644 --- a/ext/com_dotnet/com_wrapper.c +++ b/ext/com_dotnet/com_wrapper.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -280,9 +278,9 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex( * and expose it as a COM exception */ if (wFlags & DISPATCH_PROPERTYGET) { - retval = zend_read_property(Z_OBJCE(disp->object), &disp->object, Z_STRVAL_P(name), Z_STRLEN_P(name)+1, 1, &rv); + retval = zend_read_property(Z_OBJCE(disp->object), Z_OBJ(disp->object), Z_STRVAL_P(name), Z_STRLEN_P(name)+1, 1, &rv); } else if (wFlags & DISPATCH_PROPERTYPUT) { - zend_update_property(Z_OBJCE(disp->object), &disp->object, Z_STRVAL_P(name), Z_STRLEN_P(name), ¶ms[0]); + zend_update_property(Z_OBJCE(disp->object), Z_OBJ(disp->object), Z_STRVAL_P(name), Z_STRLEN_P(name), ¶ms[0]); } else if (wFlags & DISPATCH_METHOD) { zend_try { retval = &rv; @@ -499,7 +497,7 @@ static void generate_dispids(php_dispatchex *disp) char namebuf[32]; if (keytype == HASH_KEY_IS_LONG) { - snprintf(namebuf, sizeof(namebuf), "%d", pid); + snprintf(namebuf, sizeof(namebuf), ZEND_ULONG_FMT, pid); name = zend_string_init(namebuf, strlen(namebuf), 0); } else { zend_string_addref(name); diff --git a/ext/com_dotnet/php_com_dotnet.h b/ext/com_dotnet/php_com_dotnet.h index 50894158f5..025e1a7dd0 100644 --- a/ext/com_dotnet/php_com_dotnet.h +++ b/ext/com_dotnet/php_com_dotnet.h @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -51,7 +49,7 @@ ZEND_END_MODULE_GLOBALS(com_dotnet) ZEND_TSRMLS_CACHE_EXTERN() #endif -extern ZEND_DECLARE_MODULE_GLOBALS(com_dotnet); +ZEND_EXTERN_MODULE_GLOBALS(com_dotnet) #define COMG(v) ZEND_MODULE_GLOBALS_ACCESSOR(com_dotnet, v) #endif /* PHP_COM_DOTNET_H */ diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h index 8481138699..e80bf6e312 100644 --- a/ext/com_dotnet/php_com_dotnet_internal.h +++ b/ext/com_dotnet/php_com_dotnet_internal.h @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -72,32 +70,26 @@ zend_class_entry *php_com_variant_class_entry, *php_com_exception_class_entry, * /* com_handlers.c */ zend_object* php_com_object_new(zend_class_entry *ce); -zend_object* php_com_object_clone(zval *object); +zend_object* php_com_object_clone(zend_object *object); void php_com_object_free_storage(zend_object *object); zend_object_handlers php_com_object_handlers; void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable); /* com_saproxy.c */ zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *object, int by_ref); -int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index); +int php_com_saproxy_create(zend_object *com_object, zval *proxy_out, zval *index); /* com_olechar.c */ PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring, size_t *string_len, int codepage); -PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, +PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(const char *string, size_t string_len, int codepage); BSTR php_com_string_to_bstr(zend_string *string, int codepage); zend_string *php_com_bstr_to_string(BSTR bstr, int codepage); /* com_com.c */ -PHP_FUNCTION(com_create_instance); -PHP_FUNCTION(com_event_sink); -PHP_FUNCTION(com_create_guid); -PHP_FUNCTION(com_print_typeinfo); -PHP_FUNCTION(com_message_pump); -PHP_FUNCTION(com_load_typelib); -PHP_FUNCTION(com_get_active_object); +PHP_METHOD(com, __construct); HRESULT php_com_invoke_helper(php_com_dotnet_object *obj, DISPID id_member, WORD flags, DISPPARAMS *disp_params, VARIANT *v, int silent, int allow_noarg); @@ -119,33 +111,7 @@ PHP_COM_DOTNET_API IDispatch *php_com_wrapper_export(zval *val); int php_com_persist_minit(INIT_FUNC_ARGS); /* com_variant.c */ -PHP_FUNCTION(com_variant_create_instance); -PHP_FUNCTION(variant_set); -PHP_FUNCTION(variant_add); -PHP_FUNCTION(variant_cat); -PHP_FUNCTION(variant_sub); -PHP_FUNCTION(variant_mul); -PHP_FUNCTION(variant_and); -PHP_FUNCTION(variant_div); -PHP_FUNCTION(variant_eqv); -PHP_FUNCTION(variant_idiv); -PHP_FUNCTION(variant_imp); -PHP_FUNCTION(variant_mod); -PHP_FUNCTION(variant_or); -PHP_FUNCTION(variant_pow); -PHP_FUNCTION(variant_xor); -PHP_FUNCTION(variant_abs); -PHP_FUNCTION(variant_fix); -PHP_FUNCTION(variant_int); -PHP_FUNCTION(variant_neg); -PHP_FUNCTION(variant_not); -PHP_FUNCTION(variant_round); -PHP_FUNCTION(variant_cmp); -PHP_FUNCTION(variant_date_to_timestamp); -PHP_FUNCTION(variant_date_from_timestamp); -PHP_FUNCTION(variant_get_type); -PHP_FUNCTION(variant_set_type); -PHP_FUNCTION(variant_cast); +PHP_METHOD(variant, __construct); PHP_COM_DOTNET_API void php_com_variant_from_zval_with_type(VARIANT *v, zval *z, VARTYPE type, int codepage); PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage); @@ -153,7 +119,7 @@ PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepa PHP_COM_DOTNET_API int php_com_copy_variant(VARIANT *dst, VARIANT *src); /* com_dotnet.c */ -PHP_FUNCTION(com_dotnet_create_instance); +PHP_METHOD(dotnet, __construct); void php_com_dotnet_rshutdown(void); void php_com_dotnet_mshutdown(void); @@ -166,8 +132,7 @@ PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v, PHP_COM_DOTNET_API int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1); /* com_typeinfo.c */ -PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string, - int codepage, int *cached); +PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(const char *search_string, int codepage); PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codepage); PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepage); diff --git a/ext/com_dotnet/tests/27974.phpt b/ext/com_dotnet/tests/27974.phpt index 960a630304..c76dda9ed5 100644 --- a/ext/com_dotnet/tests/27974.phpt +++ b/ext/com_dotnet/tests/27974.phpt @@ -8,26 +8,26 @@ if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; error_reporting(E_ALL); try { - $v = new VARIANT(array("123", "456", "789")); - var_dump($v); - print $v[0] . "\n"; - print $v[1] . "\n"; - print $v[2] . "\n"; - $v[1] = "hello"; - foreach ($v as $item) { - var_dump($item); - } - try { - $v[3] = "shouldn't work"; - } catch (com_exception $e) { - if ($e->getCode() != DISP_E_BADINDEX) { - throw $e; - } - echo "Got BADINDEX exception OK!\n"; - } - echo "OK!"; + $v = new VARIANT(array("123", "456", "789")); + var_dump($v); + print $v[0] . "\n"; + print $v[1] . "\n"; + print $v[2] . "\n"; + $v[1] = "hello"; + foreach ($v as $item) { + var_dump($item); + } + try { + $v[3] = "shouldn't work"; + } catch (com_exception $e) { + if ($e->getCode() != DISP_E_BADINDEX) { + throw $e; + } + echo "Got BADINDEX exception OK!\n"; + } + echo "OK!"; } catch (Exception $e) { - print $e; + print $e; } ?> --EXPECT-- diff --git a/ext/com_dotnet/tests/bug33386.phpt b/ext/com_dotnet/tests/bug33386.phpt index 102e69749b..7f305d2eb5 100644 --- a/ext/com_dotnet/tests/bug33386.phpt +++ b/ext/com_dotnet/tests/bug33386.phpt @@ -15,22 +15,22 @@ class twoFuncs { } try { - $ciTF = new twoFuncs; + $ciTF = new twoFuncs; - $oScript = new COM("MSScriptControl.ScriptControl"); - $oScript->Language = "VBScript"; + $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"); - } + $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; + print $e; } ?> --EXPECT-- diff --git a/ext/com_dotnet/tests/bug34272.phpt b/ext/com_dotnet/tests/bug34272.phpt index feb63c93c3..ce8a552dfd 100644 --- a/ext/com_dotnet/tests/bug34272.phpt +++ b/ext/com_dotnet/tests/bug34272.phpt @@ -8,13 +8,13 @@ if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; error_reporting(E_ALL); try { - $dict = new COM("Scripting.Dictionary"); - $dict->add('foo', array()); - print sizeof($dict['foo'])."\n"; - $dict->add('bar', array(23)); - print sizeof($dict['bar'])." \n"; + $dict = new COM("Scripting.Dictionary"); + $dict->add('foo', array()); + print sizeof($dict['foo'])."\n"; + $dict->add('bar', array(23)); + print sizeof($dict['bar'])." \n"; } catch (Exception $e) { - print $e; + print $e; } ?> --EXPECT-- diff --git a/ext/com_dotnet/tests/bug39596.phpt b/ext/com_dotnet/tests/bug39596.phpt index bd89326560..1510db49cf 100644 --- a/ext/com_dotnet/tests/bug39596.phpt +++ b/ext/com_dotnet/tests/bug39596.phpt @@ -8,13 +8,13 @@ if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; 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"; - } + $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; + print $e; } ?> --EXPECT-- diff --git a/ext/com_dotnet/tests/bug39606.phpt b/ext/com_dotnet/tests/bug39606.phpt index 314e9ce8a2..f646c6a7c3 100644 --- a/ext/com_dotnet/tests/bug39606.phpt +++ b/ext/com_dotnet/tests/bug39606.phpt @@ -15,8 +15,6 @@ $typelib = $root.'\activeds.tlb'; var_dump(com_load_typelib($typelib)); var_dump(com_load_typelib($typelib)); ?> -===DONE=== --EXPECT-- bool(true) bool(true) -===DONE=== diff --git a/ext/com_dotnet/tests/bug45280.phpt b/ext/com_dotnet/tests/bug45280.phpt index b530083cca..393799e374 100644 --- a/ext/com_dotnet/tests/bug45280.phpt +++ b/ext/com_dotnet/tests/bug45280.phpt @@ -8,8 +8,9 @@ if (!extension_loaded("com_dotnet")){ echo "skip COM/.Net support not present"; <?php $dict = new COM("Scripting.Dictionary"); +$reflection = new ReflectionObject($dict); ob_start(); -ReflectionObject::export($dict); +echo $reflection; ob_get_clean(); echo 'done'; diff --git a/ext/com_dotnet/tests/bug49192.phpt b/ext/com_dotnet/tests/bug49192.phpt index e16c1358b1..cd85a9a64c 100644 --- a/ext/com_dotnet/tests/bug49192.phpt +++ b/ext/com_dotnet/tests/bug49192.phpt @@ -3,23 +3,9 @@ Bug #49192 (PHP crashes when GC invoked on COM object) --SKIPIF-- <?php if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?> ---XFAIL-- -1 --FILE-- <?php -// this test fails to load ADO -// -// a change in windows longhorn x64(affecting vista, 7, 8, 2008, 2008r2) broke ADO. -// -// there is a fix available, but user has to install it. -// given that ADO was deprecated a long time ago in favor of newer APIs, -// I don't think its worth the trouble of making the user install the fix to -// get an accurate test run. its better to just not run the test or expect it to fail. -// -// see: http://support.microsoft.com/kb/2517589 -// see: http://www.infoq.com/news/2011/10/ADO-Win7 - $dbConnection = new Com('ADODB.Connection'); var_dump(gc_collect_cycles()); ?> diff --git a/ext/com_dotnet/tests/bug66431_0.phpt b/ext/com_dotnet/tests/bug66431_0.phpt index e022c18e12..4a0062a7e1 100644 --- a/ext/com_dotnet/tests/bug66431_0.phpt +++ b/ext/com_dotnet/tests/bug66431_0.phpt @@ -22,12 +22,11 @@ $result = ($check_text == $text); var_dump($result); if (!$result) { - echo "Expected: '$check_text'\n"; - echo "Have: '$text'\n"; + echo "Expected: '$check_text'\n"; + echo "Have: '$text'\n"; } ?> -===DONE=== --CLEAN-- <?php @@ -39,4 +38,3 @@ if (file_exists($fpath)) { ?> --EXPECT-- bool(true) -===DONE=== diff --git a/ext/com_dotnet/tests/bug66431_1.phpt b/ext/com_dotnet/tests/bug66431_1.phpt index e68e411125..e99131d27b 100644 --- a/ext/com_dotnet/tests/bug66431_1.phpt +++ b/ext/com_dotnet/tests/bug66431_1.phpt @@ -40,12 +40,11 @@ $result = (trim($check_text) == $text); var_dump($result); if (!$result) { - echo "Expected: '$check_text'\n"; - echo "Have: '$text'\n"; + echo "Expected: '$check_text'\n"; + echo "Have: '$text'\n"; } ?> -===DONE=== --CLEAN-- <?php @@ -57,4 +56,3 @@ if (file_exists($fpath)) { ?> --EXPECT-- bool(true) -===DONE=== diff --git a/ext/com_dotnet/tests/bug73679.phpt b/ext/com_dotnet/tests/bug73679.phpt index 47de9b10c7..235fd3e33e 100644 --- a/ext/com_dotnet/tests/bug73679.phpt +++ b/ext/com_dotnet/tests/bug73679.phpt @@ -17,6 +17,6 @@ echo $stack->Pop() . $stack->Pop(); --EXPECTF-- Fatal error: Uncaught com_exception: Could not create .Net object - invalid codepage! in %sbug73679.php:%d Stack trace: -#0 %sbug73679.php(%d): dotnet->dotnet('mscorlib', 'System.Collecti...', -2200000000) +#0 %sbug73679.php(%d): dotnet->__construct('mscorlib', 'System.Collecti...', -2200000000) #1 {main} thrown in %sbug73679.php on line %d diff --git a/ext/com_dotnet/tests/bug77177.phpt b/ext/com_dotnet/tests/bug77177.phpt index 901358248c..8fcfd5a378 100644 --- a/ext/com_dotnet/tests/bug77177.phpt +++ b/ext/com_dotnet/tests/bug77177.phpt @@ -31,7 +31,6 @@ foreach ($strings as $string) { var_dump(unserialize($string)); } ?> -===DONE=== --EXPECTF-- Exception: Serialization of 'com' is not allowed Exception: Serialization of 'dotnet' is not allowed @@ -54,4 +53,3 @@ Warning: Erroneous data format for unserializing 'variant' in %s on line %d Notice: unserialize(): Error at offset 17 of 18 bytes in %s on line %d bool(false) -===DONE=== diff --git a/ext/com_dotnet/tests/bug77578.phpt b/ext/com_dotnet/tests/bug77578.phpt index e68494468e..910f24909b 100644 --- a/ext/com_dotnet/tests/bug77578.phpt +++ b/ext/com_dotnet/tests/bug77578.phpt @@ -15,9 +15,7 @@ $command = "$php $iniopt -d com.autoregister_typelib=1 -r \"new COM('WbemScripti exec($command, $output, $status); var_dump($output, $status); ?> -===DONE=== --EXPECT-- array(0) { } int(0) -===DONE=== diff --git a/ext/com_dotnet/tests/bug77621.phpt b/ext/com_dotnet/tests/bug77621.phpt index 5c24494637..32e879dcd0 100644 --- a/ext/com_dotnet/tests/bug77621.phpt +++ b/ext/com_dotnet/tests/bug77621.phpt @@ -12,7 +12,5 @@ define('ADSTYPE_INVALID', 0); $root = dirname(array_change_key_case($_SERVER, CASE_UPPER)['COMSPEC']); com_load_typelib("$root\activeds.tlb"); ?> -===DONE=== --EXPECTF-- Warning: com_load_typelib(): Type library constant ADSTYPE_INVALID is already defined in %s on line %d -===DONE=== diff --git a/ext/com_dotnet/tests/variants.phpt b/ext/com_dotnet/tests/variants.phpt index a99e896680..0bcd473f61 100644 --- a/ext/com_dotnet/tests/variants.phpt +++ b/ext/com_dotnet/tests/variants.phpt @@ -10,34 +10,34 @@ error_reporting(E_ALL); $v = new VARIANT(); if (VT_EMPTY != variant_get_type($v)) { - echo "VT_EMPTY: bork\n"; + echo "VT_EMPTY: bork\n"; } $values = array(VT_I4 => 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'); + '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()); - } - } - } + $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!"; diff --git a/ext/com_dotnet/tests/variants_x64.phpt b/ext/com_dotnet/tests/variants_x64.phpt index e9e7c23b97..88f9f3e126 100644 --- a/ext/com_dotnet/tests/variants_x64.phpt +++ b/ext/com_dotnet/tests/variants_x64.phpt @@ -13,34 +13,34 @@ error_reporting(E_ALL); $v = new VARIANT(); if (VT_EMPTY != variant_get_type($v)) { - echo "VT_EMPTY: bork\n"; + 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'); + '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()); - } - } - } + $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!"; |