Index: includes/registry.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/registry.inc,v
retrieving revision 1.13
diff -u -r1.13 registry.inc
--- includes/registry.inc	3 Apr 2009 17:41:32 -0000	1.13
+++ includes/registry.inc	4 May 2009 19:20:17 -0000
@@ -41,9 +41,11 @@
   _registry_get_resource_name();
   // Get the list of files we are going to parse.
   $files = array();
-  foreach (module_rebuild_cache() as $module) {
+  $module_cache = module_rebuild_cache();
+  foreach ($module_cache as $module) {
     if ($module->status) {
-      $dir = dirname($module->filepath);
+      // Store the module directory for use in hook_registry_files_alter().
+      $module_cache[$module]['dir'] = $dir = dirname($module->filepath);
       foreach ($module->info['files'] as $file) {
         $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight);
       }
@@ -52,6 +54,13 @@
   foreach (file_scan_directory('includes', '/\.inc$/') as $filename => $file) {
     $files["$filename"] = array('module' => '', 'weight' => 0);
   }
+  drupal_set_message(print_r($module_cache, TRUE));
+
+  // Allow modules to manually modify the list of files before the registry
+  // parses them. The $module_cache provides the info file information that
+  // contains the list of files that can be used to add files provided
+  // by disabled modules.
+  drupal_alter('registry_files', $files, $module_cache);
 
   foreach (registry_get_parsed_files() as $filename => $file) {
     // Add the md5 to those files we've already parsed.
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.31
diff -u -r1.31 system.api.php
--- modules/system/system.api.php	28 Apr 2009 00:27:06 -0000	1.31
+++ modules/system/system.api.php	4 May 2009 19:20:17 -0000
@@ -1693,5 +1693,44 @@
 }
 
 /**
+ * Perform necessary alterations to the list of files parsed by the registry.
+ *
+ * Modules can manually modify the list of files before the registry parses
+ * them. The $module_cache provides the info file information that contains the
+ * list of files that can be used to add files provided by disabled modules.
+ *
+ * Implementing hooks on behalf of another module can be done by implementing
+ * the hook in a file and changing the module related to the file before the
+ * registry parses the file. In the example bellow, hook_token() is implemented
+ * by the token module on behalf of the node module. The associated module for
+ * the file containing node_token() is changed to the node module.
+ *
+ * @param $files
+ *   List of files to be parsed by the registry. The list will contain file
+ *   found in each enabled module's info file and the includes directory. The
+ *   array is keyed by the file path and contains an array of the related module
+ *   name and weight.
+ *
+ *   For example:
+ *   @code
+ *     $files["modules/system/system.module"] = array(
+ *       'module' => 'system',
+ *       'weight' => 0,
+ *     );
+ *   @endcode
+ * @param $module_cache
+ *   List of all the files provided by modules in the system, as returned by
+ *   module_rebuild_cache(). The array contains an additional key, 'dir', added
+ *   by _registry_rebuild(). The example shows how to take advantage of the
+ *   key.
+ *
+ * @see _registry_rebuild()
+ * @see module_rebuild_cache().
+ */
+function hook_registry_files_alter($files, $module_cache) {
+  $files[$module_cache['token']['dir'] . '/token.node.inc']['module'] = 'node';
+}
+
+/**
  * @} End of "addtogroup hooks".
  */
