Re: ZE2 and classes
| From: | (Marcus Börger) | Date: | Tue, 19 Nov 2002 11:44:57 +0000 |
| Subject: | Re: ZE2 and classes | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-91323@lists.php.net to get a copy of this message | ||
I am thinking about about documentation assistance for user
functions and for the documentation team.
marcus
At 10:41 19.11.2002, Wez Furlong wrote:
php.net/get_defined_functions and php.net/get_class_methods not good enough for you? ;-) What's the long term aim? --Wez. On Tue, 19 Nov 2002, Marcus [iso-8859-1] Börger wrote: I have experimented with the code below. The main thing is to introduce a function that can return a list of all available functions (this is a first step to something bigger...). At this point i have three problems: 1) When i create a function it is shown in the result :-) 2) When i create a class it is shown twice (same goes with methods) :-( 3) When i look for internal classes there is the problem that the the function entries do not know there scope (class). In other words the connection between zend_class_entry.function_table ->> zend_function is a one way link because zend_function.scope==NULL :-(( For the moment: I know that i can fetch the scop easily if it is missing by using apply_func_args_t type functions instead of apply_func_arg_t and passing the scope to add_function_info. But for me it seems to be a problem in the zend engine. Example 1: [marcus@zaphod php4-HEAD]$ php -r 'class zz_c { function zz_c() {echo"zz_inst\n";}; static function zz_sf() {};};$o=new zz_c();$l=function_list();sort($l);var_dump($l);' | grep zz zz_inst string(10) "class zz_c" string(10) "class zz_c" string(18) "static zz_c::zz_sf" string(18) "static zz_c::zz_sf" string(2) "zz" string(10) "zz_c::zz_c" string(10) "zz_c::zz_c" Example 2: searching for methods of class defined in ext/xslt [marcus@zaphod php4-HEAD]$ php -r 'var_dump(function_list());' | grep domnode string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" string(7) "domnode" /* {{{ add_function_info */ static int add_function_info(zend_function *func, zval *return_value TSRMLS_DC) {char *f; if (func->internal_function.handler !=zif_display_disabled_function) {/* ?? internal_function->type = ZEND_INTERNAL_FUNCTION; */ if (func->common.scope) { if (func->common.is_static) { spprintf(&f, 0, "static %s::%s",func->common.scope->name, func->common.function_name);} else { spprintf(&f, 0, "%s::%s",func->common.scope->name, func->common.function_name);} } else { f = estrdup(func->common.function_name); } add_next_index_string(return_value, f, 0); } return 0;} /* }}} */ /* {{{ add_class_info */ static int add_class_info(zend_class_entry **zclass, zval *return_value TSRMLS_DC) {char *f; spprintf(&f, 0, "class %s", (*zclass)->name); add_next_index_string(return_value, f, 0); zend_hash_apply_with_argument(&(*zclass)->function_table,(apply_func_arg_t)add_function_info, return_value TSRMLS_CC);return 0;} /* }}} */ /* {{{ proto array function_list()Returns an array of all php functions */PHP_FUNCTION(function_list) {if (ZEND_NUM_ARGS()) { WRONG_PARAM_COUNT; }if (array_init(return_value) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable toinitialize array");RETURN_FALSE; }zend_hash_apply_with_argument(EG(function_table),(apply_func_arg_t)add_function_info, return_value TSRMLS_CC);zend_hash_apply_with_argument(EG(class_table), (apply_func_arg_t)add_class_info, return_value TSRMLS_CC);} /* }}} */ ------------------->>> mailto:mail@marcus-boerger.de <<<------------------ "We are animals among animals, all children of matter, save that we are the more disarmed. But since, unlike animals, we know that we must die, let us prepare for that moment by enjoying the life that has been given us by chance and for chance."Umberto Eco, The island of the day before--------------------->>> http://marcus-boerger.de <<<---------------------