mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
* Use new Zend macros for standardized definition of classes.
* Reverse bogus shutdown order. * Use the new object/class support of Zend to make the dir functions work again.
This commit is contained in:
parent
f1f4e6f478
commit
7a167cd0c1
5 changed files with 64 additions and 48 deletions
|
@ -879,15 +879,14 @@ void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_r
|
||||||
|
|
||||||
void php_register_COM_class()
|
void php_register_COM_class()
|
||||||
{
|
{
|
||||||
zend_class_entry class_entry, *registered_class;
|
zend_class_entry com_class_entry;
|
||||||
|
|
||||||
class_entry.name = strdup("COM");
|
INIT_OVERLOADED_CLASS_ENTRY(com_class_entry, "COM", NULL,
|
||||||
class_entry.name_length = sizeof("COM")-1;
|
php_COM_call_function_handler,
|
||||||
|
php_COM_get_property_handler,
|
||||||
|
php_COM_set_property_handler);
|
||||||
|
|
||||||
class_entry.handle_property_get = php_COM_get_property_handler;
|
register_internal_class(&com_class_entry);
|
||||||
class_entry.handle_property_set = php_COM_set_property_handler;
|
|
||||||
class_entry.handle_function_call = php_COM_call_function_handler;
|
|
||||||
registered_class = register_internal_class(&class_entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1974,15 +1974,14 @@ void test_class_call_function(INTERNAL_FUNCTION_PARAMETERS, zend_property_refere
|
||||||
|
|
||||||
void test_class_startup()
|
void test_class_startup()
|
||||||
{
|
{
|
||||||
zend_class_entry class_entry;
|
zend_class_entry test_class_entry;
|
||||||
|
|
||||||
class_entry.name = strdup("TestClass");
|
INIT_OVERLOADED_CLASS_ENTRY(test_class_entry, "TestClass", NULL,
|
||||||
class_entry.name_length = sizeof("TestClass")-1;
|
test_class_call_function,
|
||||||
|
test_class_get_property,
|
||||||
|
test_class_set_property);
|
||||||
|
|
||||||
class_entry.handle_property_get = test_class_get_property;
|
register_internal_class(&test_class_entry);
|
||||||
class_entry.handle_property_set = test_class_set_property;
|
|
||||||
class_entry.handle_function_call = test_class_call_function;
|
|
||||||
register_internal_class(&class_entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,29 +51,41 @@
|
||||||
#include "win32/readdir.h"
|
#include "win32/readdir.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef THREAD_SAFE
|
|
||||||
static int dirp_id = 0;
|
static int dirp_id = 0;
|
||||||
static int le_dirp;
|
static int le_dirp;
|
||||||
#endif
|
static zend_class_entry *dir_class_entry_ptr;
|
||||||
|
|
||||||
function_entry php3_dir_functions[] = {
|
static zend_function_entry php_dir_functions[] = {
|
||||||
{"opendir", php3_opendir, NULL},
|
PHP_FE(opendir, NULL)
|
||||||
{"closedir", php3_closedir, NULL},
|
PHP_FE(closedir, NULL)
|
||||||
{"chdir", php3_chdir, NULL},
|
PHP_FE(chdir, NULL)
|
||||||
{"rewinddir", php3_rewinddir, NULL},
|
PHP_FE(rewinddir, NULL)
|
||||||
{"readdir", php3_readdir, NULL},
|
PHP_FE(readdir, NULL)
|
||||||
{"dir", php3_getdir, NULL},
|
PHP_FALIAS(dir, getdir, NULL)
|
||||||
{NULL, NULL, NULL}
|
{NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static zend_function_entry php_dir_class_functions[] = {
|
||||||
|
PHP_FALIAS(close, closedir, NULL)
|
||||||
|
PHP_FALIAS(rewind, rewinddir, NULL)
|
||||||
|
PHP_FALIAS(read, readdir, NULL)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
php3_module_entry php3_dir_module_entry = {
|
php3_module_entry php3_dir_module_entry = {
|
||||||
"PHP_dir", php3_dir_functions, php3_minit_dir, NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
|
"PHP_dir", php_dir_functions, php3_minit_dir, NULL, NULL, NULL, NULL, STANDARD_MODULE_PROPERTIES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int php3_minit_dir(INIT_FUNC_ARGS)
|
int php3_minit_dir(INIT_FUNC_ARGS)
|
||||||
{
|
{
|
||||||
|
zend_class_entry dir_class_entry;
|
||||||
|
|
||||||
le_dirp = register_list_destructors(closedir,NULL);
|
le_dirp = register_list_destructors(closedir,NULL);
|
||||||
|
|
||||||
|
INIT_CLASS_ENTRY(dir_class_entry, "Directory", php_dir_class_functions);
|
||||||
|
dir_class_entry_ptr = register_internal_class(&dir_class_entry);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,18 +120,19 @@ PHP_FUNCTION(opendir)
|
||||||
Close directory connection identified by the dir_handle */
|
Close directory connection identified by the dir_handle */
|
||||||
PHP_FUNCTION(closedir)
|
PHP_FUNCTION(closedir)
|
||||||
{
|
{
|
||||||
pval *id, *tmp;
|
pval *id, **tmp;
|
||||||
int id_to_find;
|
int id_to_find;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
int dirp_type;
|
int dirp_type;
|
||||||
|
|
||||||
if (ARG_COUNT(ht) == 0) {
|
if (ARG_COUNT(ht) == 0) {
|
||||||
if (getThis(&id) == SUCCESS) {
|
id = getThis();
|
||||||
if (_php3_hash_find(id->value.ht, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
|
if (id) {
|
||||||
|
if (_php3_hash_find(id->value.obj.properties, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
|
||||||
php3_error(E_WARNING, "unable to find my handle property");
|
php3_error(E_WARNING, "unable to find my handle property");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
id_to_find = tmp->value.lval;
|
id_to_find = (*tmp)->value.lval;
|
||||||
} else {
|
} else {
|
||||||
id_to_find = dirp_id;
|
id_to_find = dirp_id;
|
||||||
}
|
}
|
||||||
|
@ -164,18 +177,19 @@ PHP_FUNCTION(chdir)
|
||||||
Rewind dir_handle back to the start */
|
Rewind dir_handle back to the start */
|
||||||
PHP_FUNCTION(rewinddir)
|
PHP_FUNCTION(rewinddir)
|
||||||
{
|
{
|
||||||
pval *id, *tmp;
|
pval *id, **tmp;
|
||||||
int id_to_find;
|
int id_to_find;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
int dirp_type;
|
int dirp_type;
|
||||||
|
|
||||||
if (ARG_COUNT(ht) == 0) {
|
if (ARG_COUNT(ht) == 0) {
|
||||||
if (getThis(&id) == SUCCESS) {
|
id = getThis();
|
||||||
if (_php3_hash_find(id->value.ht, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
|
if (id) {
|
||||||
|
if (_php3_hash_find(id->value.obj.properties, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
|
||||||
php3_error(E_WARNING, "unable to find my handle property");
|
php3_error(E_WARNING, "unable to find my handle property");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
id_to_find = tmp->value.lval;
|
id_to_find = (*tmp)->value.lval;
|
||||||
} else {
|
} else {
|
||||||
id_to_find = dirp_id;
|
id_to_find = dirp_id;
|
||||||
}
|
}
|
||||||
|
@ -199,19 +213,20 @@ PHP_FUNCTION(rewinddir)
|
||||||
Read directory entry from dir_handle */
|
Read directory entry from dir_handle */
|
||||||
PHP_FUNCTION(readdir)
|
PHP_FUNCTION(readdir)
|
||||||
{
|
{
|
||||||
pval *id, *tmp;
|
pval *id, **tmp;
|
||||||
int id_to_find;
|
int id_to_find;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
int dirp_type;
|
int dirp_type;
|
||||||
struct dirent *direntp;
|
struct dirent *direntp;
|
||||||
|
|
||||||
if (ARG_COUNT(ht) == 0) {
|
if (ARG_COUNT(ht) == 0) {
|
||||||
if (getThis(&id) == SUCCESS) {
|
id = getThis();
|
||||||
if (_php3_hash_find(id->value.ht, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
|
if (id) {
|
||||||
|
if (_php3_hash_find(id->value.obj.properties, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
|
||||||
php3_error(E_WARNING, "unable to find my handle property");
|
php3_error(E_WARNING, "unable to find my handle property");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
id_to_find = tmp->value.lval;
|
id_to_find = (*tmp)->value.lval;
|
||||||
} else {
|
} else {
|
||||||
id_to_find = dirp_id;
|
id_to_find = dirp_id;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +252,8 @@ PHP_FUNCTION(readdir)
|
||||||
|
|
||||||
/* {{{ proto class dir(string directory)
|
/* {{{ proto class dir(string directory)
|
||||||
Directory class with properties, handle and class and methods read, rewind and close */
|
Directory class with properties, handle and class and methods read, rewind and close */
|
||||||
PHP_FUNCTION(getdir) {
|
PHP_FUNCTION(getdir)
|
||||||
|
{
|
||||||
pval *arg;
|
pval *arg;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -259,12 +275,9 @@ PHP_FUNCTION(getdir) {
|
||||||
dirp_id = ret;
|
dirp_id = ret;
|
||||||
|
|
||||||
/* construct an object with some methods */
|
/* construct an object with some methods */
|
||||||
object_init(return_value);
|
object_init_ex(return_value, dir_class_entry_ptr);
|
||||||
add_property_long(return_value, "handle", ret);
|
add_property_long(return_value, "handle", ret);
|
||||||
add_property_stringl(return_value, "path", arg->value.str.val, arg->value.str.len, 1);
|
add_property_stringl(return_value, "path", arg->value.str.val, arg->value.str.len, 1);
|
||||||
add_method(return_value, "read", php3_readdir);
|
|
||||||
add_method(return_value, "rewind", php3_rewinddir);
|
|
||||||
add_method(return_value, "close", php3_closedir);
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
|
@ -701,8 +701,8 @@ void php_request_shutdown(void *dummy)
|
||||||
|
|
||||||
|
|
||||||
shutdown_scanner(CLS_C);
|
shutdown_scanner(CLS_C);
|
||||||
shutdown_compiler(CLS_C);
|
|
||||||
shutdown_executor(ELS_C);
|
shutdown_executor(ELS_C);
|
||||||
|
shutdown_compiler(CLS_C);
|
||||||
|
|
||||||
sapi_deactivate(SLS_C);
|
sapi_deactivate(SLS_C);
|
||||||
|
|
||||||
|
|
17
testobj
17
testobj
|
@ -1,9 +1,14 @@
|
||||||
<?
|
<?
|
||||||
|
|
||||||
//$a = new TestClass;
|
class foobar {
|
||||||
$a->foo = 5;
|
function foobar() {
|
||||||
$foo = 456;
|
print "foobar!\n";
|
||||||
|
$this->initialized = 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
print $a->foobar[2]["testing 123".$foo]->barbara."\n";
|
//$foo = new foobar or die("Unable to construct foobar\n");
|
||||||
print "---\n";
|
$word = new COm("word.application");
|
||||||
$a->foobar[2]["testing 123".$foo]->barbara=5;
|
$word->visible = true;
|
||||||
|
sleep(5);
|
||||||
|
$word->quit();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue