helly Sat Feb 25 21:17:18 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/reflection php_reflection.c Log: - Add ReflectionExtension::getDependencies() http://cvs.php.net/viewcvs.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.27&r2=1.164.2.28&diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.164.2.27 php-src/ext/reflection/php_reflection.c:1.164.2.28 --- php-src/ext/reflection/php_reflection.c:1.164.2.27 Sat Feb 25 18:25:44 2006 +++ php-src/ext/reflection/php_reflection.c Sat Feb 25 21:17:18 2006 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.c,v 1.164.2.27 2006/02/25 18:25:44 helly Exp $ */ +/* $Id: php_reflection.c,v 1.164.2.28 2006/02/25 21:17:18 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -871,6 +871,41 @@ module->module_number, module->name, (module->version == NO_VERSION_YET) ? "<no_version>" : module->version); + if (module->deps) { + zend_module_dep* dep = module->deps; + + string_printf(str, "\n - Dependencies {\n"); + + while(dep->name) { + string_printf(str, "%s Dependency [ %s (", indent, dep->name); + + switch(dep->type) { + case MODULE_DEP_REQUIRED: + string_write(str, "Required", sizeof("Required") - 1); + break; + case MODULE_DEP_CONFLICTS: + string_write(str, "Conflicts", sizeof("Conflicts") - 1); + break; + case MODULE_DEP_OPTIONAL: + string_write(str, "Optional", sizeof("Optional") - 1); + break; + default: + string_write(str, "Error", sizeof("Error") - 1); /* shouldn't happen */ + break; + } + + if (dep->rel) { + string_printf(str, " %s", dep->rel); + } + if (dep->version) { + string_printf(str, " %s", dep->version); + } + string_write(str, ") ]\n", sizeof(") ]\n") - 1); + dep++; + } + string_printf(str, "%s }\n", indent); + } + { string str_ini; string_init(&str_ini); @@ -4068,6 +4103,58 @@ } /* }}} */ +/* {{{ proto public array ReflectionExtension::getDependencies() + Returns an array containing all names of all extensions this extension depends on */ +ZEND_METHOD(reflection_extension, getDependencies) +{ + reflection_object *intern; + zend_module_entry *module; + zend_module_dep *dep; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_extension_ptr, 0); + GET_REFLECTION_OBJECT_PTR(module); + + array_init(return_value); + + dep = module->deps; + + if (!dep) + { + return; + } + + while(dep->name) { + char *relation; + char *rel_type; + int len; + + switch(dep->type) { + case MODULE_DEP_REQUIRED: + rel_type = "Required"; + break; + case MODULE_DEP_CONFLICTS: + rel_type = "Conflicts"; + break; + case MODULE_DEP_OPTIONAL: + rel_type = "Optional"; + break; + default: + rel_type = "Error"; /* shouldn't happen */ + break; + } + + len = spprintf(&relation, 0, "%s%s%s%s%s", + rel_type, + dep->rel ? " " : "", + dep->rel ? dep->rel : "", + dep->version ? " " : "", + dep->version ? dep->version : ""); + add_assoc_stringl(return_value, dep->name, relation, len, 0); + dep++; + } +} +/* }}} */ + /* {{{ method tables */ static zend_function_entry reflection_exception_functions[] = { {NULL, NULL, NULL} @@ -4230,6 +4317,7 @@ ZEND_ME(reflection_extension, getINIEntries, NULL, 0) ZEND_ME(reflection_extension, getClasses, NULL, 0) ZEND_ME(reflection_extension, getClassNames, NULL, 0) + ZEND_ME(reflection_extension, getDependencies, NULL, 0) {NULL, NULL, NULL} }; /* }}} */ @@ -4344,7 +4432,7 @@ php_info_print_table_start(); php_info_print_table_header(2, "Reflection", "enabled"); - php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.27 2006/02/25 18:25:44 helly Exp $"); + php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.28 2006/02/25 21:17:18 helly Exp $"); php_info_print_table_end(); } /* }}} */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php