[pypy-svn] r40884 - pypy/dist/pypy/doc

antocuni at codespeak.net antocuni at codespeak.net
Wed Mar 21 11:15:27 CET 2007


Author: antocuni
Date: Wed Mar 21 11:15:27 2007
New Revision: 40884

Modified:
   pypy/dist/pypy/doc/getting-started.txt
Log:
Some infos on the clr module.



Modified: pypy/dist/pypy/doc/getting-started.txt
==============================================================================
--- pypy/dist/pypy/doc/getting-started.txt	(original)
+++ pypy/dist/pypy/doc/getting-started.txt	Wed Mar 21 11:15:27 2007
@@ -712,6 +712,40 @@
 fine. Once assembled, you can run the produced executable with the
 Microsoft Runtime.
 
+Trying the experimental .NET integration
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can also try the still very experimental ``clr`` module that
+enables integration with the surrounding .NET environment.  First, you
+have to tell translate.py to include the ``clr`` module::
+
+    ./translate.py --text --batch --backend=cli targetpypystandalone.py --withmod-clr
+
+Then, you can dynamically load .NET classes using the
+``clr.load_cli_class`` method. After a class has been loaded, you can
+instantiate and use it as it were a normal Python class. Special
+methods such as indexers and properties are supported using the usual
+Python syntax::
+
+    >>>> import clr
+    >>>> ArrayList = clr.load_cli_class('System.Collections', 'ArrayList')
+    >>>> obj = ArrayList()
+    >>>> obj.Add(1)
+    0
+    >>>> obj.Add(2)
+    1
+    >>>> obj.Add("foo")
+    2
+    >>>> print obj[0], obj[1], obj[2]
+    1 2 foo
+    >>>> print obj.Count
+    3
+
+At the moment the only way to load a .NET class is to explicitly use
+``clr.load_cli_class``; in the future they will be automatically
+loaded when accessing .NET namespaces as they were Python modules, as
+IronPython does.
+
 
 .. _`start reading sources`: 
 



More information about the Pypy-commit mailing list