summaryrefslogtreecommitdiff
path: root/ext/com_dotnet/com_dotnet.c
diff options
context:
space:
mode:
authorStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
committerStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
commit8defcb855ab01d9c8ab4759cb793d80149b55a8c (patch)
treeed51eb30a2cbc92b102557498fb3e4113da1bb07 /ext/com_dotnet/com_dotnet.c
parent9c7dbb0487f5991fde03873ea8f5e66d6688415f (diff)
parentbaddb1c73a170ef1d2c31bd54cddbc6e1ab596b9 (diff)
downloadphp-git-8defcb855ab01d9c8ab4759cb793d80149b55a8c.tar.gz
Merge branch 'master' of https://git.php.net/push/php-src
* 'master' of https://git.php.net/push/php-src: (6215 commits) Extra comma Moved proxy object support in ASSIGN_ADD (and family) from VM to slow paths of corresponding operators Simplification zend_get_property_info_quick() cleanup and optimization initialize lineno before calling compile file file in phar Use ADDREF instead of DUP, it must be enough. Removed old irrelevant comment fixed compilation error Fix bug #68262: Broken reference across cloned objects export functions needed for phpdbg Fixed compilation Optimized property access handlers. Removed EG(std_property_info). Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) Don't make difference between undefined and unaccessible properies when call __get() and family Don't make useless CSE array_pop/array_shift optimization check for zlib headers as well as lib for mysqlnd a realpath cache key can be int or float, catching this News entry for new curl constants News entry for new curl constants ...
Diffstat (limited to 'ext/com_dotnet/com_dotnet.c')
-rw-r--r--ext/com_dotnet/com_dotnet.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/ext/com_dotnet/com_dotnet.c b/ext/com_dotnet/com_dotnet.c
index 7fbdae15cb..ae2c6ee2f0 100644
--- a/ext/com_dotnet/com_dotnet.c
+++ b/ext/com_dotnet/com_dotnet.c
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2013 The PHP Group |
+ | Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -188,7 +188,7 @@ PHP_FUNCTION(com_dotnet_create_instance)
zval *object = getThis();
php_com_dotnet_object *obj;
char *assembly_name, *datatype_name;
- int assembly_name_len, datatype_name_len;
+ size_t assembly_name_len, datatype_name_len;
struct dotnet_runtime_stuff *stuff;
OLECHAR *oleassembly, *oletype;
BSTR oleassembly_sys, oletype_sys;
@@ -198,7 +198,8 @@ PHP_FUNCTION(com_dotnet_create_instance)
IUnknown *unk = NULL;
php_com_initialize(TSRMLS_C);
- if (COMG(dotnet_runtime_stuff) == NULL) {
+ stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
+ if (stuff == NULL) {
hr = dotnet_init(&where TSRMLS_CC);
if (FAILED(hr)) {
char buf[1024];
@@ -207,12 +208,38 @@ PHP_FUNCTION(com_dotnet_create_instance)
if (err)
LocalFree(err);
php_com_throw_exception(hr, buf TSRMLS_CC);
+ ZEND_CTOR_MAKE_NULL();
+ return;
+ }
+ stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
+
+ } else if (stuff->dotnet_domain == NULL) {
+ where = "ICorRuntimeHost_GetDefaultDomain";
+ hr = ICorRuntimeHost_GetDefaultDomain(stuff->dotnet_host, &unk);
+ if (FAILED(hr)) {
+ char buf[1024];
+ char *err = php_win32_error_to_msg(hr);
+ snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
+ if (err)
+ LocalFree(err);
+ php_com_throw_exception(hr, buf TSRMLS_CC);
ZVAL_NULL(object);
return;
}
- }
- stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
+ where = "QI: System._AppDomain";
+ hr = IUnknown_QueryInterface(unk, &IID_mscorlib_System_AppDomain, (LPVOID*)&stuff->dotnet_domain);
+ if (FAILED(hr)) {
+ char buf[1024];
+ char *err = php_win32_error_to_msg(hr);
+ snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
+ if (err)
+ LocalFree(err);
+ php_com_throw_exception(hr, buf TSRMLS_CC);
+ ZVAL_NULL(object);
+ return;
+ }
+ }
obj = CDNO_FETCH(object);
@@ -221,7 +248,7 @@ PHP_FUNCTION(com_dotnet_create_instance)
&datatype_name, &datatype_name_len,
&obj->code_page)) {
php_com_throw_exception(E_INVALIDARG, "Could not create .Net object - invalid arguments!" TSRMLS_CC);
- ZVAL_NULL(object);
+ ZEND_CTOR_MAKE_NULL();
return;
}
@@ -287,7 +314,7 @@ PHP_FUNCTION(com_dotnet_create_instance)
LocalFree(err);
}
php_com_throw_exception(hr, buf TSRMLS_CC);
- ZVAL_NULL(object);
+ ZEND_CTOR_MAKE_NULL();
return;
}
}