[pypy-svn] r48379 - pypy/branch/clr-module-improvements/pypy/module/clr

regmee at codespeak.net regmee at codespeak.net
Thu Nov 8 00:13:08 CET 2007


Author: regmee
Date: Thu Nov  8 00:13:07 2007
New Revision: 48379

Modified:
   pypy/branch/clr-module-improvements/pypy/module/clr/__init__.py
   pypy/branch/clr-module-improvements/pypy/module/clr/app_importer.py
   pypy/branch/clr-module-improvements/pypy/module/clr/interp_clr.py
Log:
successful import for System.Math

Modified: pypy/branch/clr-module-improvements/pypy/module/clr/__init__.py
==============================================================================
--- pypy/branch/clr-module-improvements/pypy/module/clr/__init__.py	(original)
+++ pypy/branch/clr-module-improvements/pypy/module/clr/__init__.py	Thu Nov  8 00:13:07 2007
@@ -7,7 +7,7 @@
     """CLR module"""
 
     appleveldefs = {
-        #'dotnetimporter': 'app_importer.importer'
+        'dotnetimporter': 'app_importer.importer'
         }
     
     interpleveldefs = {
@@ -19,5 +19,5 @@
     def setup_after_space_initialization(self):
         self.space.appexec([self], """(clr_module):
             import sys
-            #sys.meta_path.append(clr_module.dotnetimporter())
+            sys.meta_path.append(clr_module.dotnetimporter())
             """)

Modified: pypy/branch/clr-module-improvements/pypy/module/clr/app_importer.py
==============================================================================
--- pypy/branch/clr-module-improvements/pypy/module/clr/app_importer.py	(original)
+++ pypy/branch/clr-module-improvements/pypy/module/clr/app_importer.py	Thu Nov  8 00:13:07 2007
@@ -17,19 +17,25 @@
         self.Names = [] 
 
     def load_module(self, fullname):
-        try:
-            return sys.modules[fullname]
-        except KeyError:
-            pass
+       
+        # Now since the module was not found .. Call the Loader and load it.
+        if fullname == "System.Math":
+            import clr
+            return clr.load_cli_class('System','Math')
+
+        if fullname == "System.Collections.ArrayList":
+            import clr
+            return clr.load_cli_class('System.Collections','ArrayList')
+
         # Now create a new module and append it at the end of the sys.modules list
         mod = imp.new_module(fullname)
         mod.__file__ = "<%s>" % self.__class__.__name__
         mod.__loader__ = self
         mod.__name__ = fullname
-        '''#if ispkg:
-        if :
-            mod.__path__ = []
-        exec code in mod.__dict__'''
+        #if ispkg:
+        #if :
+        #    mod.__path__ = []
+        #exec code in mod.__dict__'''
 
         # add it to the modules list
         sys.modules[fullname] = mod
@@ -50,8 +56,7 @@
             return sys.modules[fullname]
         except KeyError:
             pass
-       
-        # Now since the module was not found .. Call the Loader and load it.
+
         try:
             return self.loader
         except ImportError:

Modified: pypy/branch/clr-module-improvements/pypy/module/clr/interp_clr.py
==============================================================================
--- pypy/branch/clr-module-improvements/pypy/module/clr/interp_clr.py	(original)
+++ pypy/branch/clr-module-improvements/pypy/module/clr/interp_clr.py	Thu Nov  8 00:13:07 2007
@@ -188,6 +188,9 @@
 
        - classname: the name of the class in the specified namespace
          (e.g. ``ArrayList``).    """
+    #import sys
+    #for module in sys.modules:
+    #    print "mod ----> %s"%module
     fullname = '%s.%s' % (namespace, classname)
     w_cls = CliClassCache.get(fullname)
     if w_cls is None:



More information about the Pypy-commit mailing list