mirror of
https://github.com/php/php-src.git
synced 2024-11-29 21:04:10 +08: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
@ -879,15 +879,14 @@ void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_r
|
||||
|
||||
void php_register_COM_class()
|
||||
{
|
||||
zend_class_entry class_entry, *registered_class;
|
||||
zend_class_entry com_class_entry;
|
||||
|
||||
class_entry.name = strdup("COM");
|
||||
class_entry.name_length = sizeof("COM")-1;
|
||||
INIT_OVERLOADED_CLASS_ENTRY(com_class_entry, "COM", NULL,
|
||||
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;
|
||||
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);
|
||||
register_internal_class(&com_class_entry);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1974,15 +1974,14 @@ void test_class_call_function(INTERNAL_FUNCTION_PARAMETERS, zend_property_refere
|
||||
|
||||
void test_class_startup()
|
||||
{
|
||||
zend_class_entry class_entry;
|
||||
zend_class_entry test_class_entry;
|
||||
|
||||
class_entry.name = strdup("TestClass");
|
||||
class_entry.name_length = sizeof("TestClass")-1;
|
||||
INIT_OVERLOADED_CLASS_ENTRY(test_class_entry, "TestClass", NULL,
|
||||
test_class_call_function,
|
||||
test_class_get_property,
|
||||
test_class_set_property);
|
||||
|
||||
class_entry.handle_property_get = test_class_get_property;
|
||||
class_entry.handle_property_set = test_class_set_property;
|
||||
class_entry.handle_function_call = test_class_call_function;
|
||||
register_internal_class(&class_entry);
|
||||
register_internal_class(&test_class_entry);
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,29 +51,41 @@
|
||||
#include "win32/readdir.h"
|
||||
#endif
|
||||
|
||||
#ifndef THREAD_SAFE
|
||||
static int dirp_id = 0;
|
||||
static int le_dirp;
|
||||
#endif
|
||||
static zend_class_entry *dir_class_entry_ptr;
|
||||
|
||||
function_entry php3_dir_functions[] = {
|
||||
{"opendir", php3_opendir, NULL},
|
||||
{"closedir", php3_closedir, NULL},
|
||||
{"chdir", php3_chdir, NULL},
|
||||
{"rewinddir", php3_rewinddir, NULL},
|
||||
{"readdir", php3_readdir, NULL},
|
||||
{"dir", php3_getdir, NULL},
|
||||
static zend_function_entry php_dir_functions[] = {
|
||||
PHP_FE(opendir, NULL)
|
||||
PHP_FE(closedir, NULL)
|
||||
PHP_FE(chdir, NULL)
|
||||
PHP_FE(rewinddir, NULL)
|
||||
PHP_FE(readdir, NULL)
|
||||
PHP_FALIAS(dir, getdir, 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 = {
|
||||
"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)
|
||||
{
|
||||
zend_class_entry dir_class_entry;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -108,18 +120,19 @@ PHP_FUNCTION(opendir)
|
||||
Close directory connection identified by the dir_handle */
|
||||
PHP_FUNCTION(closedir)
|
||||
{
|
||||
pval *id, *tmp;
|
||||
pval *id, **tmp;
|
||||
int id_to_find;
|
||||
DIR *dirp;
|
||||
int dirp_type;
|
||||
|
||||
if (ARG_COUNT(ht) == 0) {
|
||||
if (getThis(&id) == SUCCESS) {
|
||||
if (_php3_hash_find(id->value.ht, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
|
||||
id = getThis();
|
||||
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");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
id_to_find = tmp->value.lval;
|
||||
id_to_find = (*tmp)->value.lval;
|
||||
} else {
|
||||
id_to_find = dirp_id;
|
||||
}
|
||||
@ -164,18 +177,19 @@ PHP_FUNCTION(chdir)
|
||||
Rewind dir_handle back to the start */
|
||||
PHP_FUNCTION(rewinddir)
|
||||
{
|
||||
pval *id, *tmp;
|
||||
pval *id, **tmp;
|
||||
int id_to_find;
|
||||
DIR *dirp;
|
||||
int dirp_type;
|
||||
|
||||
if (ARG_COUNT(ht) == 0) {
|
||||
if (getThis(&id) == SUCCESS) {
|
||||
if (_php3_hash_find(id->value.ht, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
|
||||
id = getThis();
|
||||
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");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
id_to_find = tmp->value.lval;
|
||||
id_to_find = (*tmp)->value.lval;
|
||||
} else {
|
||||
id_to_find = dirp_id;
|
||||
}
|
||||
@ -199,19 +213,20 @@ PHP_FUNCTION(rewinddir)
|
||||
Read directory entry from dir_handle */
|
||||
PHP_FUNCTION(readdir)
|
||||
{
|
||||
pval *id, *tmp;
|
||||
pval *id, **tmp;
|
||||
int id_to_find;
|
||||
DIR *dirp;
|
||||
int dirp_type;
|
||||
struct dirent *direntp;
|
||||
|
||||
if (ARG_COUNT(ht) == 0) {
|
||||
if (getThis(&id) == SUCCESS) {
|
||||
if (_php3_hash_find(id->value.ht, "handle", sizeof("handle"), (void **)&tmp) == FAILURE) {
|
||||
id = getThis();
|
||||
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");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
id_to_find = tmp->value.lval;
|
||||
id_to_find = (*tmp)->value.lval;
|
||||
} else {
|
||||
id_to_find = dirp_id;
|
||||
}
|
||||
@ -237,7 +252,8 @@ PHP_FUNCTION(readdir)
|
||||
|
||||
/* {{{ proto class dir(string directory)
|
||||
Directory class with properties, handle and class and methods read, rewind and close */
|
||||
PHP_FUNCTION(getdir) {
|
||||
PHP_FUNCTION(getdir)
|
||||
{
|
||||
pval *arg;
|
||||
DIR *dirp;
|
||||
int ret;
|
||||
@ -259,12 +275,9 @@ PHP_FUNCTION(getdir) {
|
||||
dirp_id = ret;
|
||||
|
||||
/* 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_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_compiler(CLS_C);
|
||||
shutdown_executor(ELS_C);
|
||||
shutdown_compiler(CLS_C);
|
||||
|
||||
sapi_deactivate(SLS_C);
|
||||
|
||||
|
17
testobj
17
testobj
@ -1,9 +1,14 @@
|
||||
<?
|
||||
|
||||
//$a = new TestClass;
|
||||
$a->foo = 5;
|
||||
$foo = 456;
|
||||
class foobar {
|
||||
function foobar() {
|
||||
print "foobar!\n";
|
||||
$this->initialized = 1;
|
||||
}
|
||||
};
|
||||
|
||||
print $a->foobar[2]["testing 123".$foo]->barbara."\n";
|
||||
print "---\n";
|
||||
$a->foobar[2]["testing 123".$foo]->barbara=5;
|
||||
//$foo = new foobar or die("Unable to construct foobar\n");
|
||||
$word = new COm("word.application");
|
||||
$word->visible = true;
|
||||
sleep(5);
|
||||
$word->quit();
|
||||
|
Loading…
Reference in New Issue
Block a user