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	5 May 2009 00:40:50 -0000
@@ -41,9 +41,14 @@
   _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) {
+    $dir = dirname($module->filepath);
+
+    // Store the module directory for use in hook_registry_files_alter().
+    $module_cache[$module->name]->dir = $dir;
+
     if ($module->status) {
-      $dir = dirname($module->filepath);
       foreach ($module->info['files'] as $file) {
         $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight);
       }
@@ -53,6 +58,12 @@
     $files["$filename"] = array('module' => '', 'weight' => 0);
   }
 
+  // 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.
     if (isset($files[$filename])) {
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	5 May 2009 00:40:51 -0000
@@ -1693,5 +1693,45 @@
 }
 
 /**
+ * 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) {
+  $dir = $module_cache['token']->dir;
+  $files["$dir/token.node.inc"]['module'] = 'node';
+}
+
+/**
  * @} End of "addtogroup hooks".
  */
