[pypy-svn] r45721 - in pypy/branch/pypy-more-rtti-inprogress: rpython rpython/module translator/c translator/c/src

arigo at codespeak.net arigo at codespeak.net
Thu Aug 16 15:54:47 CEST 2007


Author: arigo
Date: Thu Aug 16 15:54:46 2007
New Revision: 45721

Modified:
   pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py
   pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
   pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py
   pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h
Log:
os.isatty()...


Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py	Thu Aug 16 15:54:46 2007
@@ -150,7 +150,6 @@
 
 # external function declarations
 posix = __import__(os.name)
-declare(os.isatty   , bool          , 'll_os/isatty')
 declare(os.system   , int           , 'll_os/system')
 declare(os.strerror , str           , 'll_os/strerror')
 declare(os.unlink   , noneannotation, 'll_os/unlink')

Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	Thu Aug 16 15:54:46 2007
@@ -605,6 +605,17 @@
                       "ll_os.ll_os_waitpid",
                       llimpl=os_waitpid_lltypeimpl)
 
+    @registering(os.isatty)
+    def register_os_isatty(self):
+        os_isatty = rffi.llexternal('isatty', [rffi.INT], rffi.INT)
+
+        def isatty_lltypeimpl(fd):
+            res = os_isatty(rffi.cast(rffi.INT, fd))
+            return res != 0
+
+        self.register(os.isatty, [int], bool, llimpl=isatty_lltypeimpl,
+                      export_name="ll_os.ll_os_isatty")
+
 # --------------------------- os.stat & variants ---------------------------
 
     @registering(os.fstat)
@@ -694,10 +705,6 @@
     # XXX deprecated style, this is all waiting to be converted to rffi
     __metaclass__ = ClassMethods
 
-    def ll_os_isatty(cls, fd):
-        return os.isatty(fd)
-    ll_os_isatty.suggested_primitive = True
-
     def ll_os_strerror(cls, errnum):
         return cls.to_rstr(os.strerror(errnum))
     ll_os_strerror.suggested_primitive = True

Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py	Thu Aug 16 15:54:46 2007
@@ -20,7 +20,6 @@
 # references to functions, so we cannot insert classmethods here.
 
 EXTERNALS = {
-    impl.ll_os_isatty.im_func:  'LL_os_isatty',
     impl.ll_os_strerror.im_func: 'LL_os_strerror',
     impl.ll_os_system.im_func:  'LL_os_system',
     impl.ll_os_unlink.im_func:  'LL_os_unlink',

Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h	Thu Aug 16 15:54:46 2007
@@ -57,7 +57,7 @@
 #endif
 void LL_os__exit(long status);
 
-static int geterrno(void)
+static int geterrno(void)    /* XXX only for rpython.rctypes, kill me */
 {
     return errno;
 }
@@ -69,10 +69,6 @@
 
 #include "ll_osdefs.h"
 
-int LL_os_isatty(long fd) {
-    return isatty((int)fd);
-}
-
 RPyString *LL_os_strerror(int errnum) {
 	char *res;
 	res = strerror(errnum);



More information about the Pypy-commit mailing list