[pypy-svn] r33501 - pypy/dist/pypy/translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Fri Oct 20 14:46:10 CEST 2006


Author: antocuni
Date: Fri Oct 20 14:46:09 2006
New Revision: 33501

Modified:
   pypy/dist/pypy/translator/cli/cts.py
   pypy/dist/pypy/translator/cli/dotnet.py
Log:
Support for overloads of NativeInstance bound methods.



Modified: pypy/dist/pypy/translator/cli/cts.py
==============================================================================
--- pypy/dist/pypy/translator/cli/cts.py	(original)
+++ pypy/dist/pypy/translator/cli/cts.py	Fri Oct 20 14:46:09 2006
@@ -204,14 +204,18 @@
 
         return '%s %s(%s)' % (ret_type, func_name, arg_list)
 
-    def method_signature(self, TYPE, name):
+    def method_signature(self, TYPE, name_or_desc):
         # TODO: use callvirt only when strictly necessary
         if isinstance(TYPE, ootype.Instance):
-            owner, meth = TYPE._lookup(name)
+            if isinstance(name_or_desc, ootype._overloaded_meth_desc):
+                name = name_or_desc.name
+                METH = name_or_desc.TYPE
+            else:
+                name = name_or_desc
+                owner, meth = TYPE._lookup(name)
+                METH = meth._TYPE
             class_name = self.db.class_name(TYPE)
             full_name = 'class %s::%s' % (class_name, name)
-
-            METH = meth._TYPE
             returntype = self.lltype_to_cts(METH.RESULT)
             arg_types = [self.lltype_to_cts(ARG) for ARG in METH.ARGS if ARG is not ootype.Void]
             arg_list = ', '.join(arg_types)

Modified: pypy/dist/pypy/translator/cli/dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/dotnet.py	(original)
+++ pypy/dist/pypy/translator/cli/dotnet.py	Fri Oct 20 14:46:09 2006
@@ -1,5 +1,6 @@
 from pypy.rpython.extregistry import ExtRegistryEntry
 from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.ootypesystem.ootype import meth, overload, Meth
 from pypy.annotation import model as annmodel
 from pypy.rpython.rmodel import Repr
 
@@ -126,8 +127,12 @@
         fullname = '%s%s.%s' % (assembly, namespace, name)
         ootype.Instance.__init__(self, fullname, superclass, fields, methods, _is_root, _hints)
 
+
 STRING_BUILDER = NativeInstance('[mscorlib]', 'System.Text', 'StringBuilder', ootype.ROOT, {}, {})
-STRING_BUILDER._add_methods({'Append': ootype.meth(ootype.Meth([ootype.String], STRING_BUILDER))})
+STRING_BUILDER._add_methods({'Append': meth(Meth([ootype.String], STRING_BUILDER)),
+                             'AppendLine': overload(meth(Meth([ootype.String], STRING_BUILDER)),
+                                                    meth(Meth([], STRING_BUILDER)))
+                             })
 StringBuilder = CliClass(STRING_BUILDER, {})
 
 CONSOLE = NativeInstance('[mscorlib]', 'System', 'Console', ootype.ROOT, {}, {})
@@ -138,6 +143,6 @@
                                (ootype.Float,): ootype.Float}})
 
 ARRAY_LIST = NativeInstance('[mscorlib]', 'System.Collections', 'ArrayList', ootype.ROOT, {},
-                            {'Add': ootype.meth(ootype.Meth([ootype.ROOT], ootype.Signed)),
-                             'get_Count': ootype.meth(ootype.Meth([], ootype.Signed))})
+                            {'Add': meth(Meth([ootype.ROOT], ootype.Signed)),
+                             'get_Count': meth(Meth([], ootype.Signed))})
 ArrayList = CliClass(ARRAY_LIST, {})



More information about the Pypy-commit mailing list