[pypy-svn] r22573 - pypy/dist/pypy/rpython/rctypes

gromit at codespeak.net gromit at codespeak.net
Tue Jan 24 11:06:21 CET 2006


Author: gromit
Date: Tue Jan 24 11:06:19 2006
New Revision: 22573

Added:
   pypy/dist/pypy/rpython/rctypes/implementation.py
Log:
ADD: (gromit,stephan) Added an implementation module.

Added: pypy/dist/pypy/rpython/rctypes/implementation.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/rctypes/implementation.py	Tue Jan 24 11:06:19 2006
@@ -0,0 +1,46 @@
+"""
+The rctypes implementaion is contained here.
+"""
+
+from ctypes import *
+from ctypes import _FUNCFLAG_CDECL, _FUNCFLAG_STDCALL
+from pypy.annotation.model import SomeInteger
+
+c_int.annotator_type = SomeInteger()
+
+
+class FunctionPointerAnnotation(object):
+
+        def compute_result_annotation(self, *args_s):
+            """
+            Answer the annotation of the external function's result
+            """
+            return self.restype.annotator_type
+
+
+class RCDLL(CDLL):
+    """
+    This is the restricted version of ctypes' CDLL class.
+    """
+
+    class _CdeclFuncPtr(FunctionPointerAnnotation, CDLL._CdeclFuncPtr):
+        """
+        A simple extension of ctypes function pointers that
+        implements a simple interface to the anotator.
+        """
+        _flags_ = _FUNCFLAG_CDECL
+
+
+
+class RWinDLL(WinDLL):
+    """
+    This is the restricted version of ctypes' WINDLL class
+    """
+
+    class _StdcallFuncPtr(FunctionPointerAnnotation, WinDLL._StdcallFuncPtr):
+        """
+        A simple extension of ctypes function pointers that
+        implements a simple interface to the anotator.
+        """
+        _flags_ = _FUNCFLAG_STDCALL
+



More information about the Pypy-commit mailing list