[pypy-svn] r65477 - pypy/branch/io-lang/pypy/lang/io

david at codespeak.net david at codespeak.net
Thu May 28 13:59:06 CEST 2009


Author: david
Date: Thu May 28 13:59:05 2009
New Revision: 65477

Modified:
   pypy/branch/io-lang/pypy/lang/io/register.py
Log:
add option to pass a list of aliases for a method name

Modified: pypy/branch/io-lang/pypy/lang/io/register.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/register.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/register.py	Thu May 28 13:59:05 2009
@@ -1,7 +1,13 @@
 from pypy.lang.io import model
 cfunction_definitions = {}
-def register_method(type_name, slot_name, unwrap_spec=None):
+def register_method(type_name, slot_name, unwrap_spec=None, alias=None):
+    if alias is None:
+        alias = [slot_name]
+    else:
+        alias.append(slot_name)
+        
     def register(function):
+
         if unwrap_spec is None:
             wrapper = function
         else:
@@ -34,7 +40,10 @@
                         raise ValueError, 'Unknown unwrap spec'
                 return function(space, *args)
         subdict = cfunction_definitions.setdefault(type_name, {})
-        subdict[slot_name] = wrapper
+
+        
+        for slotn in alias:
+            subdict[slotn] = wrapper
 
         return function
 



More information about the Pypy-commit mailing list