helly           Mon Feb 20 23:01:28 2006 UTC

  Modified files:              
    /php-src/ext/reflection     php_reflection.c 
  Log:
  - Add ReflectionExtension::getDependencies() to retrieve all dependencies
    of an extension as associative array "ModuleNeme" > "Relation"
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/reflection/php_reflection.c?r1=1.208&r2=1.209&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.208 
php-src/ext/reflection/php_reflection.c:1.209
--- php-src/ext/reflection/php_reflection.c:1.208       Mon Feb 20 15:28:15 2006
+++ php-src/ext/reflection/php_reflection.c     Mon Feb 20 23:01:27 2006
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_reflection.c,v 1.208 2006/02/20 15:28:15 iliaa Exp $ */
+/* $Id: php_reflection.c,v 1.209 2006/02/20 23:01:27 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -4076,6 +4076,57 @@
 }
 /* }}} */
 
+/* {{{ 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;
+               
+               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;
+               }
+
+               int 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}
@@ -4234,6 +4285,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}
 };
 /* }}} */
@@ -4346,7 +4398,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.208 
2006/02/20 15:28:15 iliaa Exp $");
+       php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.209 
2006/02/20 23:01:27 helly Exp $");
 
        php_info_print_table_end();
 } /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to