]> granicus.if.org Git - php/commitdiff
* Use new Zend macros for standardized definition of classes.
authorZeev Suraski <zeev@php.net>
Fri, 28 May 1999 11:09:39 +0000 (11:09 +0000)
committerZeev Suraski <zeev@php.net>
Fri, 28 May 1999 11:09:39 +0000 (11:09 +0000)
* Reverse bogus shutdown order.
* Use the new object/class support of Zend to make the dir functions work again.

ext/rpc/com/COM.c
ext/standard/basic_functions.c
ext/standard/dir.c
main/main.c
testobj

index 8e93d7dbd41625c1b57811fbece5436fcd256890..404d069fb4fac6a374a7986cc572792eb3c2d592 100644 (file)
@@ -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);
 }
 
 
index 2dcf8f2568f766394473a5bce64b17fe0b9a45aa..99b7a8cd2552fa5b0cc9e07b671594d875777145 100644 (file)
@@ -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);
 }
 
 
index a1dc5ccdfa28f402fba6bb68a5d667d340a54d42..4cd10202b87ff8c186f0f048ea1ea70c43cc673b 100644 (file)
 #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);
 }
 /* }}} */
 
index debb33a9b407555909840ef52673dabfe6e0d8fb..59a299ef67f3b4d94a10b1a6d8af2956fc185766 100644 (file)
@@ -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);
 
diff --git a/testobj b/testobj
index 93ea5e0f999f7c2991d841a657d17f316294e1e1..26ca69bf005b5138f6eb510c931c9149bf51b58e 100644 (file)
--- a/testobj
+++ b/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;
\ No newline at end of file
+//$foo = new foobar or die("Unable to construct foobar\n");
+$word = new COm("word.application");
+$word->visible = true;
+sleep(5);
+$word->quit();