[pypy-svn] r51179 - in pypy/dist/pypy/translator/cli: . src test
antocuni at codespeak.net
antocuni at codespeak.net
Fri Feb 1 14:41:58 CET 2008
Author: antocuni
Date: Fri Feb 1 14:41:58 2008
New Revision: 51179
Modified:
pypy/dist/pypy/translator/cli/dotnet.py
pypy/dist/pypy/translator/cli/query.py
pypy/dist/pypy/translator/cli/src/pypylib.cs
pypy/dist/pypy/translator/cli/src/query.cs
pypy/dist/pypy/translator/cli/test/test_dotnet.py
Log:
fix typeof of types defined in external assemblies
Modified: pypy/dist/pypy/translator/cli/dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/dotnet.py (original)
+++ pypy/dist/pypy/translator/cli/dotnet.py Fri Feb 1 14:41:58 2008
@@ -495,8 +495,7 @@
def typeof(cliClass):
TYPE = cliClass._INSTANCE
- name = '%s.%s' % (TYPE._namespace, TYPE._classname)
- return PythonNet.System.Type.GetType(name)
+ return PythonNet.System.Type.GetType(TYPE._assembly_qualified_name)
class Entry(ExtRegistryEntry):
_about_ = typeof
Modified: pypy/dist/pypy/translator/cli/query.py
==============================================================================
--- pypy/dist/pypy/translator/cli/query.py (original)
+++ pypy/dist/pypy/translator/cli/query.py Fri Feb 1 14:41:58 2008
@@ -33,7 +33,8 @@
except ImportError:
pass
else:
- Assembly.LoadFrom(dll)
+ ass = Assembly.LoadFrom(dll)
+ assert ass is not None
clr.AddReference(pypylib)
load_assembly(pypylib)
@@ -96,6 +97,7 @@
desc = ClassDesc()
desc.Assembly = mscorlib
desc.FullName = name
+ desc.AssemblyQualifiedName = name # XXX
desc.BaseType = 'System.Object'
desc.IsArray = True
desc.ElementType = 'System.Object' # not really true, but we need something
@@ -105,6 +107,7 @@
desc = ClassDesc()
desc.Assembly = mscorlib
desc.FullName = name
+ desc.AssemblyQualifiedName = name # XXX
desc.BaseType = 'System.Array'
desc.ElementType = itemdesc.FullName
desc.IsArray = True
@@ -154,6 +157,7 @@
# no superclass for now, will add it later
TYPE = NativeInstance(assembly, namespace, name, None, {}, {})
TYPE._is_value_type = self.IsValueType
+ TYPE._assembly_qualified_name = self.AssemblyQualifiedName
Class = CliClass(TYPE, {}, {})
self._cliclass = Class
# we need to check also for System.Array to prevent a circular recursion
Modified: pypy/dist/pypy/translator/cli/src/pypylib.cs
==============================================================================
--- pypy/dist/pypy/translator/cli/src/pypylib.cs (original)
+++ pypy/dist/pypy/translator/cli/src/pypylib.cs Fri Feb 1 14:41:58 2008
@@ -53,6 +53,7 @@
namespace pypy.runtime
{
+ public delegate int DelegateType_int__int(int a);
public delegate int DelegateType_int__int_int(int a, int b);
public class Utils
Modified: pypy/dist/pypy/translator/cli/src/query.cs
==============================================================================
--- pypy/dist/pypy/translator/cli/src/query.cs (original)
+++ pypy/dist/pypy/translator/cli/src/query.cs Fri Feb 1 14:41:58 2008
@@ -58,6 +58,7 @@
outfile.WriteLine("desc = ClassDesc()");
outfile.WriteLine("desc.Assembly = '{0}'", t.Assembly.FullName);
outfile.WriteLine("desc.FullName = '{0}'", t.FullName);
+ outfile.WriteLine("desc.AssemblyQualifiedName = '{0}'", t.AssemblyQualifiedName);
outfile.WriteLine("desc.BaseType = '{0}'", GetBaseType(t));
outfile.WriteLine("desc.IsArray = {0}", t.IsArray);
outfile.WriteLine("desc.IsValueType = {0}", t.IsValueType);
Modified: pypy/dist/pypy/translator/cli/test/test_dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_dotnet.py (original)
+++ pypy/dist/pypy/translator/cli/test/test_dotnet.py Fri Feb 1 14:41:58 2008
@@ -355,6 +355,13 @@
res = self.interpret(fn, [])
assert res is True
+ def test_typeof_pypylib(self):
+ DelegateType = CLR.pypy.runtime.DelegateType_int__int_int
+ def fn():
+ return typeof(DelegateType) is not None
+ res = self.interpret(fn, [])
+ assert res is True
+
def test_mix_None_and_instance(self):
def g(x):
return x
More information about the Pypy-commit
mailing list