From antocuni at codespeak.net Sat Sep 1 11:35:42 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Sat, 1 Sep 2007 11:35:42 +0200 (CEST) Subject: [pypy-svn] r46233 - in pypy/dist/pypy/translator/jvm: . src/pypy test Message-ID: <20070901093542.BA93981AD@code0.codespeak.net> Author: antocuni Date: Sat Sep 1 11:35:42 2007 New Revision: 46233 Modified: pypy/dist/pypy/translator/jvm/database.py pypy/dist/pypy/translator/jvm/generator.py pypy/dist/pypy/translator/jvm/opcodes.py pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java pypy/dist/pypy/translator/jvm/test/test_runtest.py Log: implement ullong_mod. Modified: pypy/dist/pypy/translator/jvm/database.py ============================================================================== --- pypy/dist/pypy/translator/jvm/database.py (original) +++ pypy/dist/pypy/translator/jvm/database.py Sat Sep 1 11:35:42 2007 @@ -404,6 +404,7 @@ ootype.Signed:jvmgen.INTTOSTRINGI, ootype.Unsigned:jvmgen.PYPYSERIALIZEUINT, ootype.SignedLongLong:jvmgen.LONGTOSTRINGL, + ootype.UnsignedLongLong: jvmgen.PYPYSERIALIZEULONG, ootype.Float:jvmgen.DOUBLETOSTRINGD, ootype.Bool:jvmgen.PYPYSERIALIZEBOOLEAN, ootype.Void:jvmgen.PYPYSERIALIZEVOID, Modified: pypy/dist/pypy/translator/jvm/generator.py ============================================================================== --- pypy/dist/pypy/translator/jvm/generator.py (original) +++ pypy/dist/pypy/translator/jvm/generator.py Sat Sep 1 11:35:42 2007 @@ -394,6 +394,7 @@ PYPYUINTCMP = Method.s(jPyPy, 'uint_cmp', (jInt,jInt,), jInt) PYPYULONGCMP = Method.s(jPyPy, 'ulong_cmp', (jLong,jLong), jInt) PYPYUINTMOD = Method.s(jPyPy, 'uint_mod', (jInt, jInt), jInt) +PYPYULONGMOD = Method.s(jPyPy, 'ulong_mod', (jLong, jLong), jLong) PYPYUINTTODOUBLE = Method.s(jPyPy, 'uint_to_double', (jInt,), jDouble) PYPYDOUBLETOUINT = Method.s(jPyPy, 'double_to_uint', (jDouble,), jInt) PYPYDOUBLETOLONG = Method.s(jPyPy, 'double_to_long', (jDouble,), jLong) #PAUL @@ -410,6 +411,7 @@ PYPYDUMPEXCWRAPPER = Method.s(jPyPy, 'dump_exc_wrapper', (jObject,), jVoid) PYPYSERIALIZEBOOLEAN = Method.s(jPyPy, 'serialize_boolean', (jBool,), jString) PYPYSERIALIZEUINT = Method.s(jPyPy, 'serialize_uint', (jInt,), jString) +PYPYSERIALIZEULONG = Method.s(jPyPy, 'serialize_ulonglong', (jLong,), jString) PYPYSERIALIZEVOID = Method.s(jPyPy, 'serialize_void', (), jString) PYPYESCAPEDCHAR = Method.s(jPyPy, 'escaped_char', (jChar,), jString) PYPYESCAPEDSTRING = Method.s(jPyPy, 'escaped_string', (jString,), jString) Modified: pypy/dist/pypy/translator/jvm/opcodes.py ============================================================================== --- pypy/dist/pypy/translator/jvm/opcodes.py (original) +++ pypy/dist/pypy/translator/jvm/opcodes.py Sat Sep 1 11:35:42 2007 @@ -210,8 +210,8 @@ 'ullong_div': jvmgen.LDIV, # valid? 'ullong_truediv': None, # TODO 'ullong_floordiv': jvmgen.LDIV, # valid? - 'ullong_mod': jvmgen.LREM, # valid? - 'ullong_mod_zer': _check_zer(jvmgen.LREM), + 'ullong_mod': jvmgen.PYPYULONGMOD, + 'ullong_mod_zer': _check_zer(jvmgen.PYPYULONGMOD), 'ullong_lt': 'ulong_less_than', 'ullong_le': 'ulong_less_equals', 'ullong_eq': 'ulong_equals', Modified: pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java ============================================================================== --- pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java (original) +++ pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java Sat Sep 1 11:35:42 2007 @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Arrays; import java.util.Map; +import java.text.DecimalFormat; /** * Class with a number of utility routines. @@ -72,6 +73,12 @@ return (int)modulo; } + public static long ulong_mod(long x, long y) { + double dx = ulong_to_double(x); + double modulo = Math.IEEEremainder(dx, y); + return (long)modulo; + } + public static int ulong_cmp(long value1, long value2) { final int VALUE2BIGGER = -1; final int VALUE1BIGGER = 1; @@ -116,6 +123,17 @@ } } + public static double ulong_to_double(long value) { + if (value >= 0) + return value; + else { + long lopart = value & 0xFFFFFFFF; + long hipart = value >>> 32; + double result = (hipart << 32) | lopart; + return result; + } + } + public static int double_to_uint(double value) { if (value <= Integer.MAX_VALUE) return (int)value; @@ -249,6 +267,13 @@ } } + public static String serialize_ulonglong(long value) + { + double d = ulong_to_double(value); + DecimalFormat fmt = new DecimalFormat("0"); + return fmt.format(d); + } + public static String serialize_boolean(boolean l) { if (l) return "True"; Modified: pypy/dist/pypy/translator/jvm/test/test_runtest.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_runtest.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_runtest.py Sat Sep 1 11:35:42 2007 @@ -1,6 +1,8 @@ +import sys from pypy.translator.jvm.test.runtest import JvmTest from pypy.translator.jvm.test.runtest import FLOAT_PRECISION from pypy.annotation.listdef import s_list_of_strings +from pypy.rlib.rarithmetic import r_ulonglong def ident(x): return x @@ -64,3 +66,6 @@ else: return None assert self.interpret(fn, [False]) is None + + def test_ullong(self): + assert self.interpret(ident, [r_ulonglong(sys.maxint+1)]) == sys.maxint+1 From antocuni at codespeak.net Sat Sep 1 14:28:48 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Sat, 1 Sep 2007 14:28:48 +0200 (CEST) Subject: [pypy-svn] r46234 - in pypy/dist/pypy/translator/jvm: . src/pypy test Message-ID: <20070901122848.BFB348226@code0.codespeak.net> Author: antocuni Date: Sat Sep 1 14:28:46 2007 New Revision: 46234 Modified: pypy/dist/pypy/translator/jvm/generator.py pypy/dist/pypy/translator/jvm/opcodes.py pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java pypy/dist/pypy/translator/jvm/test/test_op.py Log: correct implementation of uint_mul and uint_div Modified: pypy/dist/pypy/translator/jvm/generator.py ============================================================================== --- pypy/dist/pypy/translator/jvm/generator.py (original) +++ pypy/dist/pypy/translator/jvm/generator.py Sat Sep 1 14:28:46 2007 @@ -394,6 +394,8 @@ PYPYUINTCMP = Method.s(jPyPy, 'uint_cmp', (jInt,jInt,), jInt) PYPYULONGCMP = Method.s(jPyPy, 'ulong_cmp', (jLong,jLong), jInt) PYPYUINTMOD = Method.s(jPyPy, 'uint_mod', (jInt, jInt), jInt) +PYPYUINTMUL = Method.s(jPyPy, 'uint_mul', (jInt, jInt), jInt) +PYPYUINTDIV = Method.s(jPyPy, 'uint_div', (jInt, jInt), jInt) PYPYULONGMOD = Method.s(jPyPy, 'ulong_mod', (jLong, jLong), jLong) PYPYUINTTODOUBLE = Method.s(jPyPy, 'uint_to_double', (jInt,), jDouble) PYPYDOUBLETOUINT = Method.s(jPyPy, 'double_to_uint', (jDouble,), jInt) Modified: pypy/dist/pypy/translator/jvm/opcodes.py ============================================================================== --- pypy/dist/pypy/translator/jvm/opcodes.py (original) +++ pypy/dist/pypy/translator/jvm/opcodes.py Sat Sep 1 14:28:46 2007 @@ -137,10 +137,10 @@ 'uint_add': jvmgen.IADD, 'uint_sub': jvmgen.ISUB, - 'uint_mul': jvmgen.IMUL, - 'uint_div': jvmgen.IDIV, # valid? - 'uint_truediv': None, # TODO - 'uint_floordiv': jvmgen.IDIV, # valid? + 'uint_mul': jvmgen.PYPYUINTMUL, +# 'uint_div': jvmgen.IDIV, # valid? +# 'uint_truediv': None, # TODO + 'uint_floordiv': jvmgen.PYPYUINTDIV, 'uint_mod': jvmgen.PYPYUINTMOD, 'uint_lt': 'u_less_than', 'uint_le': 'u_less_equals', Modified: pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java ============================================================================== --- pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java (original) +++ pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java Sat Sep 1 14:28:46 2007 @@ -73,6 +73,20 @@ return (int)modulo; } + public static int uint_mul(int x, int y) + { + long xx = uint_to_long(x); + long yy = uint_to_long(y); + return long_to_uint(xx * yy); + } + + public static int uint_div(int x, int y) + { + long xx = uint_to_long(x); + long yy = uint_to_long(y); + return long_to_uint(xx / yy); + } + public static long ulong_mod(long x, long y) { double dx = ulong_to_double(x); double modulo = Math.IEEEremainder(dx, y); @@ -113,14 +127,7 @@ public static final double BITS16 = (double)0xFFFF; public static double uint_to_double(int value) { - if (value >= 0) - return value; - else { - long loword = value & 0xFFFF; - long hiword = value >>> 16; - double result = (hiword << 16) | loword; - return result; - } + return (double)uint_to_long(value); } public static double ulong_to_double(long value) { @@ -137,13 +144,24 @@ public static int double_to_uint(double value) { if (value <= Integer.MAX_VALUE) return (int)value; + return long_to_uint((long)value); + } - long v = (long)value; - int loword = (int)(v & 0xFFFF); - int hiword = (int)(v >>> 16); + public static int long_to_uint(long value) + { + int loword = (int)(value & 0xFFFF); + int hiword = (int)(value >>> 16); return (hiword << 16) | loword; } + public static long uint_to_long(int value) + { + long loword = value & 0xFFFF; + long hiword = value >>> 16; + long res = (hiword << 16) | loword; + return res; + } + public static long double_to_long(double value) { //if (value <= LONG_MAX) @@ -259,12 +277,8 @@ public static String serialize_uint(int i) { if (i >= 0) return Integer.toString(i); - else { - long loword = i & 0xFFFF; - long hiword = i >>> 16; - long res = (hiword << 16) | loword; - return Long.toString(res); - } + else + return Long.toString(uint_to_long(i)); } public static String serialize_ulonglong(long value) Modified: pypy/dist/pypy/translator/jvm/test/test_op.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_op.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_op.py Sat Sep 1 14:28:46 2007 @@ -6,9 +6,6 @@ class TestOperations(JvmTest, BaseTestOperations): - def test_operations(self): - py.test.skip("Backend lacks appropriate precision") - def test_abs(self): py.test.skip("Backend lacks appropriate precision") From antocuni at codespeak.net Sat Sep 1 14:35:53 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Sat, 1 Sep 2007 14:35:53 +0200 (CEST) Subject: [pypy-svn] r46235 - in pypy/dist/pypy/translator/jvm: . test Message-ID: <20070901123553.0FBE6822A@code0.codespeak.net> Author: antocuni Date: Sat Sep 1 14:35:51 2007 New Revision: 46235 Modified: pypy/dist/pypy/translator/jvm/opcodes.py pypy/dist/pypy/translator/jvm/test/test_op.py Log: all tests in test_op pass! Modified: pypy/dist/pypy/translator/jvm/opcodes.py ============================================================================== --- pypy/dist/pypy/translator/jvm/opcodes.py (original) +++ pypy/dist/pypy/translator/jvm/opcodes.py Sat Sep 1 14:35:51 2007 @@ -7,10 +7,11 @@ from pypy.translator.oosupport.metavm import \ PushArg, PushAllArgs, StoreResult, InstructionList, New, DoNothing, Call,\ - SetField, GetField, DownCast, RuntimeNew, OOString, CastTo + SetField, GetField, DownCast, RuntimeNew, OOString, CastTo, PushPrimitive from pypy.translator.jvm.metavm import \ IndirectCall, JvmCallMethod, TranslateException, NewCustomDict, \ CastPtrToWeakAddress, CastWeakAddressToPtr +from pypy.rpython.ootypesystem import ootype import pypy.translator.jvm.generator as jvmgen import pypy.translator.jvm.typesystem as jvmtype @@ -241,6 +242,7 @@ 'cast_float_to_uint': jvmgen.PYPYDOUBLETOUINT, 'truncate_longlong_to_int': jvmgen.L2I, 'cast_longlong_to_float': jvmgen.L2D, + 'is_early_constant': [PushPrimitive(ootype.Bool, False), StoreResult] } Modified: pypy/dist/pypy/translator/jvm/test/test_op.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_op.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_op.py Sat Sep 1 14:35:51 2007 @@ -5,13 +5,5 @@ # ====> ../../oosupport/test_template/operations.py class TestOperations(JvmTest, BaseTestOperations): - - def test_abs(self): - py.test.skip("Backend lacks appropriate precision") - - def test_is_true(self): - py.test.skip("VerifyError happens. Accessing uninit reg") - - def test_is_early_constant(self): - py.test.skip("Unknown opcode is_early_constant") + pass From arigo at codespeak.net Sat Sep 1 14:38:06 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Sat, 1 Sep 2007 14:38:06 +0200 (CEST) Subject: [pypy-svn] r46236 - pypy/extradoc/talk/esug2007 Message-ID: <20070901123806.98355822D@code0.codespeak.net> Author: arigo Date: Sat Sep 1 14:38:03 2007 New Revision: 46236 Added: pypy/extradoc/talk/esug2007/ pypy/extradoc/talk/esug2007/Makefile - copied, changed from r45426, pypy/extradoc/talk/dyla2007/Makefile pypy/extradoc/talk/esug2007/abstract pypy/extradoc/talk/esug2007/beamerouterthememy.sty - copied unchanged from r45426, pypy/extradoc/talk/dyla2007/beamerouterthememy.sty pypy/extradoc/talk/esug2007/beamerthemeWarsaw.sty - copied unchanged from r45426, pypy/extradoc/talk/dyla2007/beamerthemeWarsaw.sty pypy/extradoc/talk/esug2007/talk.tex - copied, changed from r45426, pypy/extradoc/talk/dyla2007/talk.tex Log: The ESUG2007 talk, based on the Dyla'07 one - sorry, I forgot to update to the latest version - but anyway the talk was mostly only the demo, not the slides. Added: pypy/extradoc/talk/esug2007/abstract ============================================================================== --- (empty file) +++ pypy/extradoc/talk/esug2007/abstract Sat Sep 1 14:38:03 2007 @@ -0,0 +1,27 @@ + + +Description +----------- + +PyPy is a framework written in Python for generating virtual machines +for dynamic languages. The VMs are flexibly produced from a high-level +"specification" in the form of a simple interpreter for the dynamic +language. Low-level details like memory allocation and object layout +are not encoded manually, but inserted by the VM generation process. +This allows us to produce VMs that run within a wide range of execution +environments (from C-like to JVM/.NET). Interesting features can be +automatically inserted into the VMs at production time -- including a +good just-in-time compiler tuned to the dynamic language at hand. + +More than "selling" PyPy specifically, our aim in this project is to +raise interest in our approach to virtual machine construction. After a +demo and architecture overview, I will explain the context in which we +wrote PyPy, and how much of these ideas could be applied to a Smalltalk +context. + +Bio +--- + +/me has been an open source developer and post-doc working in Python on +language implementation issues for quite a few years now, after a +Ph.D. in mathematical logic at the Free University of Brussels. From arigo at codespeak.net Sun Sep 2 19:50:04 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Sun, 2 Sep 2007 19:50:04 +0200 (CEST) Subject: [pypy-svn] r46243 - in pypy/branch/pypy-more-rtti-inprogress/rpython: lltypesystem module Message-ID: <20070902175004.D3C54818D@code0.codespeak.net> Author: arigo Date: Sun Sep 2 19:50:02 2007 New Revision: 46243 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py Log: Start again with Windows porting. Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py Sun Sep 2 19:50:02 2007 @@ -44,6 +44,7 @@ if max_n is not None and fieldname == S._arrayfld: cls = build_ctypes_array(FIELDTYPE, max_n) elif isinstance(FIELDTYPE, lltype.Ptr) and FIELDTYPE.TO is S: + # XXX this is not the right hack to handle circular structures! cls = ctypes.POINTER(S._name) else: cls = get_ctypes_type(FIELDTYPE) @@ -436,6 +437,9 @@ libraries = getattr(funcptr._obj, 'libraries', None) if not libraries: cfunc = getattr(standard_c_lib, funcname, None) + # XXX magic: on Windows try to load the function from 'kernel32' too + if cfunc is None and hasattr(ctypes, 'windll'): + cfunc = getattr(ctypes.windll.kernel32, funcname, None) else: cfunc = None for libname in libraries: 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 Sun Sep 2 19:50:02 2007 @@ -30,12 +30,19 @@ register(function, [CLOCK_T], ...) """ - _includes_ = ['sys/times.h', 'utime.h', 'sys/types.h', 'unistd.h', - 'signal.h', 'wait.h'] + _includes_ = [] if not sys.platform.startswith('win'): - _includes_ += ['dirent.h', 'sys/stat.h'] - - CLOCK_T = platform.SimpleType('clock_t', rffi.INT) + _includes_ += ['dirent.h', 'sys/stat.h', + 'sys/times.h', 'utime.h', 'sys/types.h', 'unistd.h', + 'signal.h', 'wait.h'] + + CLOCK_T = platform.SimpleType('clock_t', rffi.INT) + + TMS = platform.Struct( + 'struct tms', [('tms_utime', rffi.INT), + ('tms_stime', rffi.INT), + ('tms_cutime', rffi.INT), + ('tms_cstime', rffi.INT)]) NAME_MAX = platform.DefinedConstantInteger('NAME_MAX') @@ -43,12 +50,6 @@ SEEK_CUR = platform.DefinedConstantInteger('SEEK_CUR') SEEK_END = platform.DefinedConstantInteger('SEEK_END') - TMS = platform.Struct( - 'struct tms', [('tms_utime', rffi.INT), - ('tms_stime', rffi.INT), - ('tms_cutime', rffi.INT), - ('tms_cstime', rffi.INT)]) - class RegisterOs(BaseLazyRegistering): _stringpolicy_ = 'fullauto' @@ -185,26 +186,64 @@ @registering(os.times) def register_os_times(self): - self.TMSP = lltype.Ptr(self.TMS) - os_times = self.llexternal('times', [self.TMSP], self.CLOCK_T) + if sys.platform.startswith('win'): + HANDLE = rffi.LONG + FILETIME = rffi.CStruct('_FILETIME', ('dwLowDateTime', rffi.LONG), + ('dwHighDateTime', rffi.LONG)) + GetCurrentProcess = self.llexternal('GetCurrentProcess', [], + HANDLE) + GetProcessTimes = self.llexternal('GetProcessTimes', + [HANDLE, + lltype.Ptr(FILETIME), + lltype.Ptr(FILETIME), + lltype.Ptr(FILETIME), + lltype.Ptr(FILETIME)], + lltype.Bool) + + def times_lltypeimpl(): + pcreate = lltype.malloc(FILETIME, flavor='raw') + pexit = lltype.malloc(FILETIME, flavor='raw') + pkernel = lltype.malloc(FILETIME, flavor='raw') + puser = lltype.malloc(FILETIME, flavor='raw') + hProc = GetCurrentProcess() + GetProcessTimes(hProc, pcreate, pexit, pkernel, puser) + # The fields of a FILETIME structure are the hi and lo parts + # of a 64-bit value expressed in 100 nanosecond units + # (of course). + result = (pkernel.c_dwHighDateTime*429.4967296 + + pkernel.c_dwLowDateTime*1E-7, + puser.c_dwHighDateTime*429.4967296 + + puser.c_dwLowDateTime*1E-7, + 0, 0, 0) + lltype.free(puser, flavor='raw') + lltype.free(pkernel, flavor='raw') + lltype.free(pexit, flavor='raw') + lltype.free(pcreate, flavor='raw') + return result + self.register(os.times, [], (float, float, float, float, float), + "ll_os.ll_times", llimpl=times_lltypeimpl) + return + + TMSP = lltype.Ptr(self.TMS) + os_times = self.llexternal('times', [TMSP], self.CLOCK_T) # Here is a random extra platform parameter which is important. # Strictly speaking, this should probably be retrieved at runtime, not # at translation time. - self.CLOCK_TICKS_PER_SECOND = float(os.sysconf('SC_CLK_TCK')) + CLOCK_TICKS_PER_SECOND = float(os.sysconf('SC_CLK_TCK')) def times_lltypeimpl(): - l_tmsbuf = lltype.malloc(self.TMSP.TO, flavor='raw') + l_tmsbuf = lltype.malloc(TMSP.TO, flavor='raw') try: result = os_times(l_tmsbuf) if result == -1: raise OSError(rffi.get_errno(), "times failed") return ( - l_tmsbuf.c_tms_utime / self.CLOCK_TICKS_PER_SECOND, - l_tmsbuf.c_tms_stime / self.CLOCK_TICKS_PER_SECOND, - l_tmsbuf.c_tms_cutime / self.CLOCK_TICKS_PER_SECOND, - l_tmsbuf.c_tms_cstime / self.CLOCK_TICKS_PER_SECOND, - result / self.CLOCK_TICKS_PER_SECOND) + l_tmsbuf.c_tms_utime / CLOCK_TICKS_PER_SECOND, + l_tmsbuf.c_tms_stime / CLOCK_TICKS_PER_SECOND, + l_tmsbuf.c_tms_cutime / CLOCK_TICKS_PER_SECOND, + l_tmsbuf.c_tms_cstime / CLOCK_TICKS_PER_SECOND, + result / CLOCK_TICKS_PER_SECOND) finally: lltype.free(l_tmsbuf, flavor='raw') self.register(os.times, [], (float, float, float, float, float), @@ -264,11 +303,11 @@ return extdef([], (str, str, str, str, str), "ll_os.ll_uname", llimpl=uname_llimpl) - @registering(os.getuid) + @registering_if(os, 'getuid') def register_os_getuid(self): return self.extdef_for_os_function_returning_int('getuid') - @registering(os.geteuid) + @registering_if(os, 'geteuid') def register_os_geteuid(self): return self.extdef_for_os_function_returning_int('geteuid') @@ -428,7 +467,12 @@ @registering(os.access) def register_os_access(self): - os_access = self.llexternal('access', [rffi.CCHARP, rffi.INT], + if sys.platform.startswith('win'): + name = '_access' + else: + name = 'access' + os_access = self.llexternal(name, + [rffi.CCHARP, rffi.INT], rffi.INT) def access_llimpl(path, mode): From arigo at codespeak.net Sun Sep 2 19:56:10 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Sun, 2 Sep 2007 19:56:10 +0200 (CEST) Subject: [pypy-svn] r46244 - in pypy/branch/pypy-more-rtti-inprogress/rpython/module: . test Message-ID: <20070902175610.061798187@code0.codespeak.net> Author: arigo Date: Sun Sep 2 19:56:09 2007 New Revision: 46244 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py pypy/branch/pypy-more-rtti-inprogress/rpython/module/test/test_ll_os.py Log: test_ll_os.py passes on Windows. 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 Sun Sep 2 19:56:09 2007 @@ -50,6 +50,11 @@ SEEK_CUR = platform.DefinedConstantInteger('SEEK_CUR') SEEK_END = platform.DefinedConstantInteger('SEEK_END') +if sys.platform.startswith('win'): + underscore_on_windows = '_' +else: + underscore_on_windows = '' + class RegisterOs(BaseLazyRegistering): _stringpolicy_ = 'fullauto' @@ -467,11 +472,7 @@ @registering(os.access) def register_os_access(self): - if sys.platform.startswith('win'): - name = '_access' - else: - name = 'access' - os_access = self.llexternal(name, + os_access = self.llexternal(underscore_on_windows + 'access', [rffi.CCHARP, rffi.INT], rffi.INT) @@ -488,7 +489,7 @@ @registering(os.getcwd) def register_os_getcwd(self): - os_getcwd = self.llexternal('getcwd', + os_getcwd = self.llexternal(underscore_on_windows + 'getcwd', [rffi.CCHARP, rffi.SIZE_T], rffi.CCHARP, stringpolicy='noauto') Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/test/test_ll_os.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/module/test/test_ll_os.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/test/test_ll_os.py Sun Sep 2 19:56:09 2007 @@ -51,6 +51,8 @@ def test_os_wstar(): from pypy.rpython.module.ll_os import RegisterOs for name in RegisterOs.w_star: + if not hasattr(os, name): + continue def fun(s): return getattr(os, name)(s) From fijal at codespeak.net Sun Sep 2 20:03:49 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 2 Sep 2007 20:03:49 +0200 (CEST) Subject: [pypy-svn] r46245 - in pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem: . test Message-ID: <20070902180349.D23028187@code0.codespeak.net> Author: fijal Date: Sun Sep 2 20:03:49 2007 New Revision: 46245 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/test/test_ll2ctypes.py Log: Remove this hack and skip the test Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py Sun Sep 2 20:03:49 2007 @@ -43,9 +43,6 @@ FIELDTYPE = S._flds[fieldname] if max_n is not None and fieldname == S._arrayfld: cls = build_ctypes_array(FIELDTYPE, max_n) - elif isinstance(FIELDTYPE, lltype.Ptr) and FIELDTYPE.TO is S: - # XXX this is not the right hack to handle circular structures! - cls = ctypes.POINTER(S._name) else: cls = get_ctypes_type(FIELDTYPE) fields.append((fieldname, cls)) Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/test/test_ll2ctypes.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/test/test_ll2ctypes.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/test/test_ll2ctypes.py Sun Sep 2 20:03:49 2007 @@ -406,7 +406,7 @@ lltype.free(s, flavor='raw') def test_recursive_struct(self): - # XXX sucky way of creating those + py.test.skip("Not implemented") SX = lltype.ForwardReference() S1 = lltype.Struct('S1', ('x', lltype.Ptr(SX))) S1.x.TO.become(S1) From santagada at codespeak.net Sun Sep 2 23:53:13 2007 From: santagada at codespeak.net (santagada at codespeak.net) Date: Sun, 2 Sep 2007 23:53:13 +0200 (CEST) Subject: [pypy-svn] r46247 - pypy/branch/pypy-more-rtti-inprogress/rpython/module Message-ID: <20070902215313.1995381FD@code0.codespeak.net> Author: santagada Date: Sun Sep 2 23:53:12 2007 New Revision: 46247 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py Log: in the wait manpage for os x and freebsd this is the right place for the signal header. 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 Sun Sep 2 23:53:12 2007 @@ -34,7 +34,7 @@ if not sys.platform.startswith('win'): _includes_ += ['dirent.h', 'sys/stat.h', 'sys/times.h', 'utime.h', 'sys/types.h', 'unistd.h', - 'signal.h', 'wait.h'] + 'signal.h', 'sys/wait.h'] CLOCK_T = platform.SimpleType('clock_t', rffi.INT) From santagada at codespeak.net Sun Sep 2 23:59:19 2007 From: santagada at codespeak.net (santagada at codespeak.net) Date: Sun, 2 Sep 2007 23:59:19 +0200 (CEST) Subject: [pypy-svn] r46248 - pypy/dist/pypy/doc Message-ID: <20070902215919.4E26A81FD@code0.codespeak.net> Author: santagada Date: Sun Sep 2 23:59:18 2007 New Revision: 46248 Modified: pypy/dist/pypy/doc/faq.txt Log: little doc correction, put the ctypes version needed and saying that cpython 2.5 is supported now Modified: pypy/dist/pypy/doc/faq.txt ============================================================================== --- pypy/dist/pypy/doc/faq.txt (original) +++ pypy/dist/pypy/doc/faq.txt Sun Sep 2 23:59:18 2007 @@ -51,8 +51,8 @@ OS X and mostly works under Windows too (but is tested there less extensively). PyPy needs a CPython running on the target platform to bootstrap, as cross compilation is not really meant to work yet. -At the moment you need CPython 2.4 for the translation process, 2.5 is -not fully supported. +At the moment you need CPython 2.4 (with ctypes 0.9.9.6 or newer) or +CPython 2.5 for the translation process. Currently (due to time restrictions) we are not trying hard to support PyPy in a 64 bit environment. While things seem to mostly work, a few From arigo at codespeak.net Mon Sep 3 11:00:24 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 11:00:24 +0200 (CEST) Subject: [pypy-svn] r46257 - in pypy/branch/pypy-more-rtti-inprogress/rpython: . module Message-ID: <20070903090024.A7452815C@code0.codespeak.net> Author: arigo Date: Mon Sep 3 11:00:24 2007 New Revision: 46257 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/extfunc.py pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py Log: More Windozification... Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/extfunc.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/extfunc.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/extfunc.py Mon Sep 3 11:00:24 2007 @@ -95,6 +95,9 @@ __ATTRIBUTES = ['includes', 'include_dirs'] def configure(self, CConfig): + classes_seen = self.__dict__.setdefault('__classes_seen', {}) + if CConfig in classes_seen: + return from pypy.rpython.tool import rffi_platform as platform # copy some stuff for item in self.__ATTRIBUTES: @@ -102,6 +105,7 @@ if value: setattr(self, '_%s_' % item, value) self.__dict__.update(platform.configure(CConfig)) + classes_seen[CConfig] = True def llexternal(self, *args, **kwds): kwds = kwds.copy() @@ -117,6 +121,9 @@ kwds['stringpolicy'] = stringpolicy return rffi.llexternal(*args, **kwds) + def _freeze_(self): + return True + class genericcallable(object): """ A way to specify the callable annotation, but deferred until we have bookkeeper Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py Mon Sep 3 11:00:24 2007 @@ -19,12 +19,14 @@ CLOCK_T = platform.SimpleType('clock_t', rffi.INT) TIMEVAL = platform.Struct('struct timeval', [('tv_sec', rffi.INT), ('tv_usec', rffi.INT)]) - TIMEB = platform.Struct('struct timeb', [('time', rffi.INT), - ('millitm', rffi.INT)]) TIME_T = platform.SimpleType('time_t', rffi.INT) HAVE_GETTIMEOFDAY = platform.Has('gettimeofday') HAVE_FTIME = platform.Has('ftime') +class CConfigForFTime: + TIMEB = platform.Struct('struct timeb', [('time', rffi.INT), + ('millitm', rffi.INT)]) + constant_names = ['CLOCKS_PER_SEC', 'CLK_TCK', 'EINTR'] for const in constant_names: setattr(CConfig, const, platform.DefinedConstantInteger(const)) @@ -41,7 +43,6 @@ else: self.CLOCKS_PER_SEC = self.CLK_TCK self.TIMEVALP = lltype.Ptr(self.TIMEVAL) - self.TIMEBP = lltype.Ptr(self.TIMEB) @registering(time.time) def register_time_time(self): @@ -60,9 +61,9 @@ c_gettimeofday = None if self.HAVE_FTIME: - c_ftime = self.llexternal('ftime', [self.TIMEBP], lltype.Void) - else: - c_ftime = None # not to confuse flow objspace + self.configure(CConfigForFTime) + c_ftime = self.llexternal('ftime', [lltype.Ptr(self.TIMEB)], + lltype.Void) c_time = self.llexternal('time', [rffi.VOIDP], self.TIME_T) From arigo at codespeak.net Mon Sep 3 11:13:19 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 11:13:19 +0200 (CEST) Subject: [pypy-svn] r46258 - in pypy/branch/pypy-more-rtti-inprogress: objspace/flow rpython/module Message-ID: <20070903091319.06E258153@code0.codespeak.net> Author: arigo Date: Mon Sep 3 11:13:18 2007 New Revision: 46258 Modified: pypy/branch/pypy-more-rtti-inprogress/objspace/flow/objspace.py pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py Log: time.time() -> win Modified: pypy/branch/pypy-more-rtti-inprogress/objspace/flow/objspace.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/objspace/flow/objspace.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/objspace/flow/objspace.py Mon Sep 3 11:13:18 2007 @@ -241,7 +241,9 @@ if func.func_closure is None: closure = None else: - closure = [extract_cell_content(c) for c in func.func_closure] + closure = [extract_cell_content(c, name, func) + for c, name in zip(func.func_closure, + func.func_code.co_freevars)] # CallableFactory.pycall may add class_ to functions that are methods name = func.func_name class_ = getattr(func, 'class_', None) @@ -558,7 +560,7 @@ OverflowError) # for the float case del _add_exceptions, _add_except_ovf -def extract_cell_content(c): +def extract_cell_content(c, varname, func): """Get the value contained in a CPython 'cell', as read through the func_closure of a function object.""" # yuk! this is all I could come up with that works in Python 2.2 too @@ -572,7 +574,11 @@ x = X() x_cell, = (lambda: x).func_closure x_cell == c - return x.other # crashes if the cell is actually empty + try: + return x.other # crashes if the cell is actually empty + except AttributeError: + raise Exception("in %r, the free variable %r has no value" % ( + func, varname)) def make_op(name, symbol, arity, specialnames): if hasattr(FlowObjSpace, name): Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py Mon Sep 3 11:13:18 2007 @@ -46,51 +46,50 @@ @registering(time.time) def register_time_time(self): - if sys.platform == 'win32': - xxx + # AWFUL + if self.HAVE_GETTIMEOFDAY: + if self.GETTIMEOFDAY_NO_TZ: + c_gettimeofday = self.llexternal('gettimeofday', + [self.TIMEVALP], rffi.INT) + else: + c_gettimeofday = self.llexternal('gettimeofday', + [self.TIMEVALP, rffi.VOIDP], rffi.INT) + else: + c_gettimeofday = None + + if self.HAVE_FTIME: + self.configure(CConfigForFTime) + c_ftime = self.llexternal('ftime', [lltype.Ptr(self.TIMEB)], + lltype.Void) else: - # AWFUL + c_ftime = None # to not confuse the flow space + + c_time = self.llexternal('time', [rffi.VOIDP], self.TIME_T) + + def time_time_llimpl(): + void = lltype.nullptr(rffi.VOIDP.TO) + result = -1.0 if self.HAVE_GETTIMEOFDAY: + t = lltype.malloc(self.TIMEVAL, flavor='raw') + if self.GETTIMEOFDAY_NO_TZ: - c_gettimeofday = self.llexternal('gettimeofday', - [self.TIMEVALP], rffi.INT) + if c_gettimeofday(t) == 0: + result = float(t.c_tv_sec) + \ + float(t.c_tv_usec) * 0.000001 else: - c_gettimeofday = self.llexternal('gettimeofday', - [self.TIMEVALP, rffi.VOIDP], rffi.INT) - else: - c_gettimeofday = None - + if c_gettimeofday(t, void) == 0: + result = float(t.c_tv_sec) + \ + float(t.c_tv_usec) * 0.000001 + lltype.free(t, flavor='raw') + if result != -1: + return result if self.HAVE_FTIME: - self.configure(CConfigForFTime) - c_ftime = self.llexternal('ftime', [lltype.Ptr(self.TIMEB)], - lltype.Void) - - c_time = self.llexternal('time', [rffi.VOIDP], self.TIME_T) - - def time_time_llimpl(): - void = lltype.nullptr(rffi.VOIDP.TO) - result = -1.0 - if self.HAVE_GETTIMEOFDAY: - t = lltype.malloc(self.TIMEVAL, flavor='raw') - - if self.GETTIMEOFDAY_NO_TZ: - if c_gettimeofday(t) == 0: - result = float(t.c_tv_sec) + \ - float(t.c_tv_usec) * 0.000001 - else: - if c_gettimeofday(t, void) == 0: - result = float(t.c_tv_sec) + \ - float(t.c_tv_usec) * 0.000001 - lltype.free(t, flavor='raw') - if result != -1: - return result - if self.HAVE_FTIME: - t = lltype.malloc(self.TIMEB, flavor='raw') - c_ftime(t) - result = float(int(t.c_time)) + float(int(t.c_millitm)) * 0.001 - lltype.free(t, flavor='raw') - return result - return float(c_time(void)) + t = lltype.malloc(self.TIMEB, flavor='raw') + c_ftime(t) + result = float(int(t.c_time)) + float(int(t.c_millitm)) * 0.001 + lltype.free(t, flavor='raw') + return result + return float(c_time(void)) return extdef([], float, llimpl=time_time_llimpl, export_name='ll_time.ll_time_time') From arigo at codespeak.net Mon Sep 3 11:33:27 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 11:33:27 +0200 (CEST) Subject: [pypy-svn] r46259 - pypy/branch/pypy-more-rtti-inprogress/rpython/module Message-ID: <20070903093327.DBAC48153@code0.codespeak.net> Author: arigo Date: Mon Sep 3 11:33:27 2007 New Revision: 46259 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py Log: finish ll_time -> win. Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py Mon Sep 3 11:33:27 2007 @@ -97,9 +97,28 @@ @registering(time.clock) def register_time_clock(self): c_clock = self.llexternal('clock', [], self.CLOCK_T) - if sys.platform == 'win32': - xxx + # hacking to avoid LARGE_INTEGER which is a union... + A = lltype.FixedSizeArray(lltype.SignedLongLong, 1) + QueryPerformanceCounter = self.llexternal( + 'QueryPerformanceCounter', [lltype.Ptr(A)], lltype.Void) + QueryPerformanceFrequency = self.llexternal( + 'QueryPerformanceFrequency', [lltype.Ptr(A)], rffi.INT) + class State(object): + pass + state = State() + state.divisor = 0.0 + def time_clock_llimpl(): + a = lltype.malloc(A, flavor='raw') + if state.divisor == 0.0: + QueryPerformanceCounter(a) + state.counter_start = a[0] + QueryPerformanceFrequency(a) + state.divisor = float(a[0]) + QueryPerformanceCounter(a) + diff = a[0] - state.counter_start + lltype.free(a, flavor='raw') + return float(diff) / state.divisor else: def time_clock_llimpl(): result = c_clock() @@ -111,15 +130,20 @@ @registering(time.sleep) def register_time_sleep(self): if sys.platform == 'win32': - xxx + MAX = sys.maxint + Sleep = self.llexternal('Sleep', [rffi.ULONG], lltype.Void) + def time_sleep_llimpl(secs): + millisecs = secs * 1000.0 + while millisecs > MAX: + Sleep(MAX) + millisecs -= MAX + Sleep(rffi.cast(rffi.ULONG, int(millisecs))) else: c_select = self.llexternal('select', [rffi.INT, rffi.VOIDP, rffi.VOIDP, rffi.VOIDP, self.TIMEVALP], rffi.INT) def time_sleep_llimpl(secs): - # XXX cannot put it into try: finally: because - # someone forgotten to call hop.exception_is_here void = lltype.nullptr(rffi.VOIDP.TO) t = lltype.malloc(self.TIMEVAL, flavor='raw') try: From antocuni at codespeak.net Mon Sep 3 11:35:14 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 11:35:14 +0200 (CEST) Subject: [pypy-svn] r46260 - pypy/dist/pypy/translator/jvm Message-ID: <20070903093514.90BF38153@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 11:35:13 2007 New Revision: 46260 Modified: pypy/dist/pypy/translator/jvm/genjvm.py Log: recompile *.java files only when needed. Modified: pypy/dist/pypy/translator/jvm/genjvm.py ============================================================================== --- pypy/dist/pypy/translator/jvm/genjvm.py (original) +++ pypy/dist/pypy/translator/jvm/genjvm.py Mon Sep 3 11:35:13 2007 @@ -108,21 +108,27 @@ def _compile_helper(self, clsnms): # HACK: compile the Java helper class. Should eventually # use rte.py - tocompile = [] - for clsnm in clsnms: - pypycls = self.classdir.join(clsnm + '.class') - if not pypycls.check(): - tocompile.append(clsnm) - if tocompile: - thisdir = py.magic.autopath().dirpath() - javasrcs = [str(thisdir.join('src/pypy', clsnm + '.java')) for - clsnm in tocompile] - self._invoke([getoption('javac'), - '-nowarn', - '-d', str(self.classdir)]+ - javasrcs, - True) - + thisdir = py.magic.autopath().dirpath() + rootdir = thisdir.join('src') + srcdir = rootdir.join('pypy') + javafiles = srcdir.listdir('*.java') + classfiles = srcdir.listdir('*.class') + + recompile = True + if classfiles: + last_modified_java = max([java.mtime() for java in javafiles]) + last_modified_class = max([cls.mtime() for cls in classfiles]) + if last_modified_java < last_modified_class: + recompile = False + + if recompile: + log.red('Compiling java classes') + javasrcs = [str(srcdir.join(clsnm + '.java')) for clsnm in clsnms] + self._invoke([getoption('javac'), '-nowarn', '-d', str(rootdir)] + javasrcs, True) + + # copy .class files to classdir + for classfile in srcdir.listdir('*.class'): + classfile.copy(self.classdir.join('pypy')) def compile(self): """ From antocuni at codespeak.net Mon Sep 3 11:37:05 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 11:37:05 +0200 (CEST) Subject: [pypy-svn] r46261 - pypy/dist/pypy/translator/jvm/test Message-ID: <20070903093705.DE8CA815C@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 11:37:04 2007 New Revision: 46261 Modified: pypy/dist/pypy/translator/jvm/test/test_cast.py Log: test_uint_to_float passes Modified: pypy/dist/pypy/translator/jvm/test/test_cast.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_cast.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_cast.py Mon Sep 3 11:37:04 2007 @@ -3,7 +3,4 @@ from pypy.translator.oosupport.test_template.cast import BaseTestCast class TestCast(BaseTestCast, JvmTest): - - def test_uint_to_float(self): - # This is most likely with how we render uints when we print them, and they get parsed. - py.test.skip('Same issue seen in other tests with uints... 2147450880.0 == 2147483648.0') + pass From arigo at codespeak.net Mon Sep 3 12:23:36 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 12:23:36 +0200 (CEST) Subject: [pypy-svn] r46263 - in pypy/branch/pypy-more-rtti-inprogress: rpython/module translator/c/test Message-ID: <20070903102336.8A5F7816A@code0.codespeak.net> Author: arigo Date: Mon Sep 3 12:23:36 2007 New Revision: 46263 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_stat.py pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py Log: os.stat() returns bogus times on Windows. Skip the tests for now. This check-in contains the start of the "correct" implementation and the reason why I stopped working on it for now. Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_stat.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_stat.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_stat.py Mon Sep 3 12:23:36 2007 @@ -199,3 +199,58 @@ "ll_os.ll_os_%s" % (name,), llimpl=func_with_new_name(os_mystat_llimpl, 'os_%s_llimpl' % (name,))) + +# ____________________________________________________________ + +if 0: + XXX - """ + disabled for now: + error codes are different when returned from the Win32 API, + which makes things a mess that I don't want to tackle now... + """ + # The CRT of Windows has a number of flaws wrt. its stat() implementation: + # - for when we implement subsecond resolution in RPython, time stamps + # would be restricted to second resolution + # - file modification times suffer from forth-and-back conversions between + # UTC and local time + # Therefore, we implement our own stat, based on the Win32 API directly. + from pypy.rpython.tool import rffi_platform as platform + + assert len(STAT_FIELDS) == 10 # no extra fields on Windows + FILETIME = rffi.CStruct('_FILETIME', ('dwLowDateTime', rffi.LONG), + ('dwHighDateTime', rffi.LONG)) + class CConfig: + GET_FILEEX_INFO_LEVELS = platform.SimpleType('GET_FILEEX_INFO_LEVELS', + rffi.INT) + GetFileExInfoStandard = platform.ConstantInteger( + 'GetFileExInfoStandard') + WIN32_FILE_ATTRIBUTE_DATA = platform.Struct( + '_WIN32_FILE_ATTRIBUTE_DATA', + [('dwFileAttributes', rffi.ULONG), + ('nFileSizeHigh', rffi.ULONG), + ('nFileSizeLow', rffi.ULONG), + ('ftCreationTime', FILETIME), + ('ftLastAccessTime', FILETIME), + ('ftCreationTime', FILETIME)]) + + globals().update(platform.configure(CConfig)) + + GetFileAttributesEx = rffi.llexternal( + 'GetFileAttributesExA', [rffi.CCHARP, + GET_FILEEX_INFO_LEVELS, + lltype.Ptr(WIN32_FILE_ATTRIBUTE_DATA)], + rffi.INT) + + def os_stat_llimpl(path): + data = lltype.malloc(WIN32_FILE_ATTRIBUTE_DATA, flavor='raw') + try: + l_path = rffi.str2charp(path) + res = GetFileAttributesEx(l_path, GetFileExInfoStandard, data) + rffi.free_charp(l_path) + if res == 0: + # ignore the GetLastError() which is a number that we cannot + # easily report... + XXX + YYY + finally: + lltype.free(data, flavor='raw') Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py Mon Sep 3 12:23:36 2007 @@ -176,6 +176,8 @@ res = f() assert res[0] == os.stat(filename).st_mode assert res[1] == os.stat(filename).st_ino + if sys.platform.startswith('win'): + py.test.skip("in-progress - bogus stat().st_time") st_ctime = res[2] if isinstance(st_ctime, float): assert st_ctime == os.stat(filename).st_ctime @@ -200,6 +202,8 @@ os.close(fd) assert st_mode == osstat.st_mode assert st_ino == osstat.st_ino + if sys.platform.startswith('win'): + py.test.skip("in-progress - bogus stat().st_time") if isinstance(st_mtime, float): assert st_mtime == osstat.st_mtime else: From arigo at codespeak.net Mon Sep 3 12:38:56 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 12:38:56 +0200 (CEST) Subject: [pypy-svn] r46266 - pypy/branch/pypy-more-rtti-inprogress/rpython/module Message-ID: <20070903103856.9828A814F@code0.codespeak.net> Author: arigo Date: Mon Sep 3 12:38:56 2007 New Revision: 46266 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py Log: Make the RPython interface to os.mkdir() always take a mode argument, which we just ignore on Windows (CPython's os.mkdir() behaves like that too). 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 Mon Sep 3 12:38:56 2007 @@ -716,21 +716,21 @@ @registering(os.mkdir) def register_os_mkdir(self): if os.name == 'nt': - ARG2 = [] # no 'mode' argument on Windows - arg2 = [] + ARG2 = [] # no 'mode' argument on Windows - just ignored else: ARG2 = [rffi.MODE_T] - arg2 = [int] os_mkdir = self.llexternal('mkdir', [rffi.CCHARP]+ARG2, rffi.INT) + IGNORE_MODE = len(ARG2) == 0 - def mkdir_llimpl(pathname, *opt_mode): - if opt_mode: - opt_mode = (opt_mode[0],) - res = os_mkdir(pathname, *opt_mode) + def mkdir_llimpl(pathname, mode): + if IGNORE_MODE: + res = os_mkdir(pathname) + else: + res = os_mkdir(pathname, mode) if res < 0: raise OSError(rffi.get_errno(), "os_mkdir failed") - return extdef([str]+arg2, s_None, llimpl=mkdir_llimpl, + return extdef([str, int], s_None, llimpl=mkdir_llimpl, export_name="ll_os.ll_os_mkdir") @registering(os.rmdir) From arigo at codespeak.net Mon Sep 3 13:40:27 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 13:40:27 +0200 (CEST) Subject: [pypy-svn] r46268 - in pypy/branch/pypy-more-rtti-inprogress/rpython: lltypesystem module Message-ID: <20070903114027.1475380C0@code0.codespeak.net> Author: arigo Date: Mon Sep 3 13:40:26 2007 New Revision: 46268 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/rffi.py pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py Log: Windozify listdir() and pipe(). Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/rffi.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/rffi.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/rffi.py Mon Sep 3 13:40:26 2007 @@ -96,6 +96,9 @@ if os.name != 'nt': TYPES.append('mode_t') TYPES.append('pid_t') +else: + MODE_T = lltype.Signed + PID_T = lltype.Signed def setup(): """ creates necessary c-level types 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 Mon Sep 3 13:40:26 2007 @@ -44,8 +44,6 @@ ('tms_cutime', rffi.INT), ('tms_cstime', rffi.INT)]) - NAME_MAX = platform.DefinedConstantInteger('NAME_MAX') - SEEK_SET = platform.DefinedConstantInteger('SEEK_SET') SEEK_CUR = platform.DefinedConstantInteger('SEEK_CUR') SEEK_END = platform.DefinedConstantInteger('SEEK_END') @@ -192,7 +190,7 @@ @registering(os.times) def register_os_times(self): if sys.platform.startswith('win'): - HANDLE = rffi.LONG + HANDLE = rffi.ULONG FILETIME = rffi.CStruct('_FILETIME', ('dwLowDateTime', rffi.LONG), ('dwHighDateTime', rffi.LONG)) GetCurrentProcess = self.llexternal('GetCurrentProcess', [], @@ -322,11 +320,7 @@ @registering(os.open) def register_os_open(self): - if os.name == 'nt': - mode_t = rffi.INT - else: - mode_t = rffi.MODE_T - os_open = self.llexternal('open', [rffi.CCHARP, rffi.INT, mode_t], + os_open = self.llexternal('open', [rffi.CCHARP, rffi.INT, rffi.MODE_T], rffi.INT) def os_open_llimpl(path, flags, mode): @@ -523,14 +517,80 @@ def register_os_listdir(self): # we need a different approach on Windows and on Posix if sys.platform.startswith('win'): - XXX # FindFirstFile, FindNextFile - else: + class CConfig: + _includes_ = ['windows.h'] + WIN32_FIND_DATA = platform.Struct('struct _WIN32_FIND_DATAA', + [('cFileName', lltype.FixedSizeArray(rffi.CHAR, 1))]) + INVALID_HANDLE_VALUE = platform.ConstantInteger( + 'INVALID_HANDLE_VALUE') + ERROR_FILE_NOT_FOUND = platform.ConstantInteger( + 'ERROR_FILE_NOT_FOUND') + ERROR_NO_MORE_FILES = platform.ConstantInteger( + 'ERROR_NO_MORE_FILES') + + config = platform.configure(CConfig) + WIN32_FIND_DATA = config['WIN32_FIND_DATA'] + INVALID_HANDLE_VALUE = config['INVALID_HANDLE_VALUE'] + ERROR_FILE_NOT_FOUND = config['ERROR_FILE_NOT_FOUND'] + ERROR_NO_MORE_FILES = config['ERROR_NO_MORE_FILES'] + LPWIN32_FIND_DATA = lltype.Ptr(WIN32_FIND_DATA) + HANDLE = rffi.ULONG + #MAX_PATH = WIN32_FIND_DATA.c_cFileName.length + + GetLastError = self.llexternal('GetLastError', [], lltype.Signed) + FindFirstFile = self.llexternal('FindFirstFile', + [rffi.CCHARP, LPWIN32_FIND_DATA], + HANDLE) + FindNextFile = self.llexternal('FindNextFile', + [HANDLE, LPWIN32_FIND_DATA], + rffi.INT) + FindClose = self.llexternal('FindClose', + [HANDLE], + rffi.INT) + + def os_listdir_llimpl(path): + if path and path[-1] not in ('/', '\\', ':'): + path += '/' + path += '*.*' + filedata = lltype.malloc(WIN32_FIND_DATA, flavor='raw') + try: + result = [] + hFindFile = FindFirstFile(path, filedata) + if hFindFile == INVALID_HANDLE_VALUE: + error = GetLastError() + if error == ERROR_FILE_NOT_FOUND: + return result + else: + # XXX guess error code :-( + raise OSError(errno.ENOENT, "FindFirstFile failed") + while True: + name = rffi.charp2str(rffi.cast(rffi.CCHARP, + filedata.c_cFileName)) + if name != "." and name != "..": # skip these + result.append(name) + if not FindNextFile(hFindFile, filedata): + break + # FindNextFile sets error to ERROR_NO_MORE_FILES if + # it got to the end of the directory + error = GetLastError() + FindClose(hFindFile) + if error == ERROR_NO_MORE_FILES: + return result + else: + # XXX guess error code :-( + raise OSError(errno.EIO, "FindNextFile failed") + finally: + lltype.free(filedata, flavor='raw') + + else: + class CConfig: + DIRENT = platform.Struct('dirent', + [('d_name', lltype.FixedSizeArray(rffi.CHAR, 1))]) + + config = platform.configure(CConfig) + DIRENT = config['DIRENT'] + DIRENTP = lltype.Ptr(DIRENT) DIRP = rffi.COpaquePtr('DIR') - DIRENTP = rffi.CStructPtr('dirent', - ('d_name', lltype.FixedSizeArray(lltype.Char, self.NAME_MAX+1)), - ) - # XXX so far, DIRENTP cannot be handled by ll2ctypes because - # it contains other fields before 'd_name', at least on Linux os_opendir = self.llexternal('opendir', [rffi.CCHARP], DIRP) os_readdir = self.llexternal('readdir', [DIRP], DIRENTP) os_closedir = self.llexternal('closedir', [DIRP], rffi.INT) @@ -555,16 +615,41 @@ raise OSError(error, "os_readdir failed") return result - return extdef([str], # a single argument which is a str - [str], # returns a list of strings - "ll_os.ll_os_listdir", - llimpl=os_listdir_llimpl) + return extdef([str], # a single argument which is a str + [str], # returns a list of strings + "ll_os.ll_os_listdir", + llimpl=os_listdir_llimpl) @registering(os.pipe) def register_os_pipe(self): # we need a different approach on Windows and on Posix if sys.platform.startswith('win'): - XXX # CreatePipe, _open_osfhandle + HANDLE = rffi.ULONG + HANDLEP = lltype.Ptr(lltype.FixedSizeArray(HANDLE, 1)) + CreatePipe = self.llexternal('CreatePipe', [HANDLEP, + HANDLEP, + rffi.VOIDP, + rffi.ULONG], + rffi.INT) + _open_osfhandle = self.llexternal('_open_osfhandle', [rffi.ULONG, + rffi.INT], + rffi.INT) + null = lltype.nullptr(rffi.VOIDP.TO) + + def os_pipe_llimpl(): + pread = lltype.malloc(HANDLEP.TO, flavor='raw') + pwrite = lltype.malloc(HANDLEP.TO, flavor='raw') + ok = CreatePipe(pread, pwrite, null, 0) + hread = pread[0] + hwrite = pwrite[0] + lltype.free(pwrite, flavor='raw') + lltype.free(pread, flavor='raw') + if not ok: # XXX guess the error, can't use GetLastError() + raise OSError(errno.EMFILE, "os_pipe failed") + fdread = _open_osfhandle(hread, 0) + fdwrite = _open_osfhandle(hwrite, 1) + return (fdread, fdwrite) + else: INT_ARRAY_P = lltype.Ptr(lltype.FixedSizeArray(rffi.INT, 2)) os_pipe = self.llexternal('pipe', [INT_ARRAY_P], rffi.INT) @@ -579,9 +664,9 @@ raise OSError(rffi.get_errno(), "os_pipe failed") return (read_fd, write_fd) - return extdef([], (int, int), - "ll_os.ll_os_pipe", - llimpl=os_pipe_llimpl) + return extdef([], (int, int), + "ll_os.ll_os_pipe", + llimpl=os_pipe_llimpl) @registering_if(os, 'readlink') def register_os_readlink(self): @@ -747,14 +832,11 @@ @registering(os.chmod) def register_os_chmod(self): - if os.name == 'nt': - MODE_T = rffi.INT - else: - MODE_T = rffi.MODE_T - os_chmod = self.llexternal('chmod', [rffi.CCHARP, MODE_T], rffi.INT) + os_chmod = self.llexternal('chmod', [rffi.CCHARP, rffi.MODE_T], + rffi.INT) def chmod_llimpl(path, mode): - res = os_chmod(path, rffi.cast(MODE_T, mode)) + res = os_chmod(path, rffi.cast(rffi.MODE_T, mode)) if res < 0: raise OSError(rffi.get_errno(), "os_chmod failed") @@ -776,14 +858,10 @@ @registering(os.umask) def register_os_umask(self): - if os.name == 'nt': - mode_t = rffi.INT - else: - mode_t = rffi.MODE_T - os_umask = self.llexternal('umask', [mode_t], mode_t) + os_umask = self.llexternal('umask', [rffi.MODE_T], rffi.MODE_T) def umask_llimpl(fd): - res = os_umask(rffi.cast(mode_t, fd)) + res = os_umask(rffi.cast(rffi.MODE_T, fd)) return rffi.cast(lltype.Signed, res) return extdef([int], int, llimpl=umask_llimpl, From arigo at codespeak.net Mon Sep 3 13:49:21 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 13:49:21 +0200 (CEST) Subject: [pypy-svn] r46270 - pypy/branch/pypy-more-rtti-inprogress/rpython/module Message-ID: <20070903114921.37C7280E9@code0.codespeak.net> Author: arigo Date: Mon Sep 3 13:49:19 2007 New Revision: 46270 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py Log: Posix fix. Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py Mon Sep 3 13:49:19 2007 @@ -24,6 +24,7 @@ HAVE_FTIME = platform.Has('ftime') class CConfigForFTime: + _includes_ = ['sys/timeb.h'] TIMEB = platform.Struct('struct timeb', [('time', rffi.INT), ('millitm', rffi.INT)]) From arigo at codespeak.net Mon Sep 3 14:11:59 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 14:11:59 +0200 (CEST) Subject: [pypy-svn] r46273 - pypy/branch/pypy-more-rtti-inprogress/rpython/test Message-ID: <20070903121159.7E8878168@code0.codespeak.net> Author: arigo Date: Mon Sep 3 14:11:56 2007 New Revision: 46273 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/test/test_llann.py Log: A test showing an annotation crash. Annoying. Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/test/test_llann.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/test/test_llann.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/test/test_llann.py Mon Sep 3 14:11:56 2007 @@ -315,7 +315,25 @@ s = self.annotate(llf, [annmodel.SomeInteger()]) assert s.unsigned == True - + def test_pbctype(self): + py.test.skip("annotation crash") + TYPE = Void + TYPE2 = Signed + def g(lst): + n = lst[0] + if isinstance(TYPE, Number): + result = 123 + else: + result = 456 + if isinstance(TYPE2, Number): + result += 1 + return result + n + def llf(): + lst = [5] + g(lst) + lst.append(6) + self.annotate(llf, []) + def test_pseudohighlevelcallable(): t = TranslationContext() t.buildannotator() From arigo at codespeak.net Mon Sep 3 14:27:47 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 14:27:47 +0200 (CEST) Subject: [pypy-svn] r46274 - in pypy/branch/pypy-more-rtti-inprogress: rpython/module translator/c/test Message-ID: <20070903122747.54CBA8132@code0.codespeak.net> Author: arigo Date: Mon Sep 3 14:27:46 2007 New Revision: 46274 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py Log: More progress, mostly test fixing. 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 Mon Sep 3 14:27:46 2007 @@ -96,7 +96,7 @@ def spawnv_llimpl(mode, path, args): mode = rffi.cast(rffi.INT, mode) l_args = rffi.liststr2charpp(args) - childpid = os_spawnv(mode, l_path, l_args) + childpid = os_spawnv(mode, path, l_args) rffi.free_charpp(l_args) if childpid == -1: raise OSError(rffi.get_errno(), "os_spawnv failed") Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py Mon Sep 3 14:27:46 2007 @@ -599,7 +599,7 @@ return mask2 f1 = compile(does_stuff, []) res = f1() - assert res == 0660 + assert res == does_stuff() if hasattr(os, 'getpid'): def test_os_getpid(): @@ -834,12 +834,12 @@ compared_with.sort() assert result == compared_with -if hasattr(posix, 'execv'): +if hasattr(posix, 'execv') and hasattr(posix, 'fork'): def test_execv(): filename = str(udir.join('test_execv.txt')) def does_stuff(): progname = str(sys.executable) - l = [progname, '-c', 'open("%s","w").write("1")' % filename] + l = [progname, '-c', 'open(%r,"w").write("1")' % filename] pid = os.fork() if pid == 0: os.execv(progname, l) @@ -866,7 +866,7 @@ l = [] l.append(progname) l.append("-c") - l.append('import os; open("%s", "w").write(os.environ["STH"])' % filename) + l.append('import os; open(%r, "w").write(os.environ["STH"])' % filename) env = {} env["STH"] = "42" env["sthelse"] = "a" @@ -884,8 +884,17 @@ def test_spawnv(): filename = str(udir.join('test_spawnv.txt')) progname = str(sys.executable) + scriptpath = udir.join('test_spawnv.py') + scriptpath.write('f=open(%r,"w")\nf.write("2")\nf.close\n' % filename) + scriptname = str(scriptpath) def does_stuff(): - l = [progname, '-c', 'open("%s","w").write("2")' % filename] + # argument quoting on Windows is completely ill-defined. + # don't let yourself be fooled by the idea that if os.spawnv() + # takes a list of strings, then the receiving program will + # nicely see these strings as arguments with no further quote + # processing. Achieving this is nearly impossible - even + # CPython doesn't try at all. + l = [progname, scriptname] pid = os.spawnv(os.P_NOWAIT, progname, l) os.waitpid(pid, 0) func = compile(does_stuff, []) From antocuni at codespeak.net Mon Sep 3 16:03:24 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 16:03:24 +0200 (CEST) Subject: [pypy-svn] r46277 - in pypy/dist/pypy/translator: jvm/test oosupport Message-ID: <20070903140324.097DC8144@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 16:03:24 2007 New Revision: 46277 Modified: pypy/dist/pypy/translator/jvm/test/test_streamio.py pypy/dist/pypy/translator/jvm/test/test_tuple.py pypy/dist/pypy/translator/oosupport/constant.py Log: this extra DUP was needed for gencli, where dict of void are represented with generic classes, but not in genjvm, where they are plain classes. This code is not even longer needed in gencli, becase of the _check_for_void_dict in CLIDictMixin! Modified: pypy/dist/pypy/translator/jvm/test/test_streamio.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_streamio.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_streamio.py Mon Sep 3 16:03:24 2007 @@ -24,25 +24,5 @@ pass class TestTextOutputFilter(JvmTest, BaseTestTextOutputFilter): - def test_write_nl(self): - py.test.skip("VerifyError - Incompatible object arguments") - - def test_write_cr(self): - py.test.skip("VerifyError - Incompatible object arguments") - - def test_write_crnl(self): - py.test.skip("VerifyError - Incompatible object arguments") - - def test_write_tell_nl(self): - py.test.skip("VerifyError - Incompatible object arguments") - - def test_write_tell_cr(self): - py.test.skip("VerifyError - Incompatible object arguments") - - def test_write_tell_crnl(self): - py.test.skip("VerifyError - Incompatible object arguments") - - def test_write_seek(self): - py.test.skip("VerifyError - Incompatible object arguments") - + pass Modified: pypy/dist/pypy/translator/jvm/test/test_tuple.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_tuple.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_tuple.py Mon Sep 3 16:03:24 2007 @@ -10,14 +10,3 @@ assert res.item0 == 1.0 and res.item1 == 1 res = self.interpret(fn, [1.0, 1.0]) assert res.item0 == 1.0 and res.item1 == 1.0 - - #v116 = oosend(('ll_contains'), (), i_0) - # Arg 01: Exception in thread "main" java.lang.VerifyError - def test_constant_tuple_contains(self): - py.test.skip("VerifyError - Incompatible object argumemt") - - def test_constant_tuple_contains2(self): - py.test.skip("VerifyError - Incompatible object argumemt") - - def test_constant_unichar_tuple_contains(self): - py.test.skip("VerifyError - Incompatible object argumemt") Modified: pypy/dist/pypy/translator/oosupport/constant.py ============================================================================== --- pypy/dist/pypy/translator/oosupport/constant.py (original) +++ pypy/dist/pypy/translator/oosupport/constant.py Mon Sep 3 16:03:24 2007 @@ -648,11 +648,7 @@ gen.add_comment(' key=%r value=%r' % (key,value)) push_constant(self.db, KEYTYPE, key, gen) gen.prepare_generic_argument(KEYTYPE) - if VALUETYPE is ootype.Void: - # special case dict of Void; for now store the key as value? - gen.dup(KEYTYPE) - else: - push_constant(self.db, VALUETYPE, value, gen) + push_constant(self.db, VALUETYPE, value, gen) gen.prepare_generic_argument(VALUETYPE) gen.call_method(SELFTYPE, 'll_set') From antocuni at codespeak.net Mon Sep 3 16:08:37 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 16:08:37 +0200 (CEST) Subject: [pypy-svn] r46278 - in pypy/dist/pypy/translator/jvm: . test Message-ID: <20070903140837.D01338144@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 16:08:37 2007 New Revision: 46278 Modified: pypy/dist/pypy/translator/jvm/constant.py pypy/dist/pypy/translator/jvm/test/test_constant.py Log: don't try to access custom eq&hash functions on a null dict. Modified: pypy/dist/pypy/translator/jvm/constant.py ============================================================================== --- pypy/dist/pypy/translator/jvm/constant.py (original) +++ pypy/dist/pypy/translator/jvm/constant.py Mon Sep 3 16:08:37 2007 @@ -88,6 +88,8 @@ # key_eq is a Python function and graph is, well, a method # graph that seems to be added to the function pointer # somewhere. Adapted from cli/constant.py + if self.value is ootype.null(self.value._TYPE): + return self.eq_jcls = self.db.record_delegate_standalone_func_impl( self.value._dict.key_eq.graph) self.hash_jcls = self.db.record_delegate_standalone_func_impl( Modified: pypy/dist/pypy/translator/jvm/test/test_constant.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_constant.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_constant.py Mon Sep 3 16:08:37 2007 @@ -101,26 +101,25 @@ assert self.interpret(fn2, [1]) == True def test_customdict_circular(self): - py.test.skip("Circular dicts are not supported in JVM") -# from pypy.rlib.objectmodel import r_dict -# def key_eq(a, b): -# return a.x[0] == b.x[0] -# def key_hash(a): -# return ord(a.x[0]) -# -# class A: -# def __init__(self, x): -# self.x = x -# a = A('foo') -# a.dict = r_dict(key_eq, key_hash) -# a.dict[a] = 42 -# def fn(b): -# if b: -# s = A('foo') -# else: -# s = A('bar') -# return a.dict[s] -# assert self.interpret(fn, [True]) == 42 + from pypy.rlib.objectmodel import r_dict + def key_eq(a, b): + return a.x[0] == b.x[0] + def key_hash(a): + return ord(a.x[0]) + + class A: + def __init__(self, x): + self.x = x + a = A('foo') + a.dict = r_dict(key_eq, key_hash) + a.dict[a] = 42 + def fn(b): + if b: + s = A('foo') + else: + s = A('bar') + return a.dict[s] + assert self.interpret(fn, [True]) == 42 def test_multiple_step(self): from pypy.translator.oosupport import constant From antocuni at codespeak.net Mon Sep 3 16:13:00 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 16:13:00 +0200 (CEST) Subject: [pypy-svn] r46279 - pypy/dist/pypy/translator/jvm/test Message-ID: <20070903141300.80D9D814D@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 16:13:00 2007 New Revision: 46279 Modified: pypy/dist/pypy/translator/jvm/test/test_dict.py Log: this test simply pass now Modified: pypy/dist/pypy/translator/jvm/test/test_dict.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_dict.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_dict.py Mon Sep 3 16:13:00 2007 @@ -6,11 +6,8 @@ def test_invalid_iterator(self): py.test.skip("test_invalid_iterator() doesn't work yet") - def test_dict_of_dict(self): - py.test.skip("hard to serialize a recursive dictionary") - def test_recursive(self): - py.test.skip("hard to serialize a recursive dictionary") + py.test.skip("JVM doesn't support recursive dicts") class TestJvmEmptyDict(JvmTest, oodict.BaseTestEmptyDict): def test_iterate_over_empty_dict(self): From arigo at codespeak.net Mon Sep 3 17:02:37 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 17:02:37 +0200 (CEST) Subject: [pypy-svn] r46280 - in pypy/branch/pypy-more-rtti-inprogress: rpython/module translator/c/test Message-ID: <20070903150237.1DBAE8168@code0.codespeak.net> Author: arigo Date: Mon Sep 3 17:02:35 2007 New Revision: 46280 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py Log: os.utime(): * Windows support * sub-second resolution support (not for Windows) 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 Mon Sep 3 17:02:35 2007 @@ -19,6 +19,12 @@ from pypy.rpython.tool import rffi_platform as platform posix = __import__(os.name) +if sys.platform.startswith('win'): + underscore_on_windows = '_' +else: + underscore_on_windows = '' + + class CConfig: """ Definitions for platform integration. @@ -32,6 +38,7 @@ """ _includes_ = [] if not sys.platform.startswith('win'): + # XXX many of these includes are not portable at all _includes_ += ['dirent.h', 'sys/stat.h', 'sys/times.h', 'utime.h', 'sys/types.h', 'unistd.h', 'signal.h', 'sys/wait.h'] @@ -43,15 +50,17 @@ ('tms_stime', rffi.INT), ('tms_cutime', rffi.INT), ('tms_cstime', rffi.INT)]) + else: + _includes_ += ['sys/utime.h'] SEEK_SET = platform.DefinedConstantInteger('SEEK_SET') SEEK_CUR = platform.DefinedConstantInteger('SEEK_CUR') SEEK_END = platform.DefinedConstantInteger('SEEK_END') -if sys.platform.startswith('win'): - underscore_on_windows = '_' -else: - underscore_on_windows = '' + HAVE_UTIMES = platform.Has('utimes') + UTIMBUF = platform.Struct('struct '+underscore_on_windows+'utimbuf', + [('actime', rffi.INT), + ('modtime', rffi.INT)]) class RegisterOs(BaseLazyRegistering): @@ -133,29 +142,49 @@ @registering(os.utime) def register_os_utime(self): - TIME_T = rffi.INT # XXX do the right thing - UTIMEBUFP = rffi.CStructPtr('utimbuf', ('actime', TIME_T), - ('modtime', TIME_T)) + UTIMBUFP = lltype.Ptr(self.UTIMBUF) + os_utime = self.llexternal('utime', [rffi.CCHARP, UTIMBUFP], rffi.INT) - # XXX sys/types.h is not portable at all - os_utime = self.llexternal('utime', [rffi.CCHARP, UTIMEBUFP], rffi.INT) + if self.HAVE_UTIMES: + class CConfig: + TIMEVAL = platform.Struct('struct timeval', [('tv_sec', rffi.LONG), + ('tv_usec', rffi.LONG)]) + config = platform.configure(CConfig) + TIMEVAL = config['TIMEVAL'] + TIMEVAL2P = lltype.Ptr(lltype.FixedSizeArray(TIMEVAL, 2)) + os_utimes = self.llexternal('utimes', [rffi.CCHARP, TIMEVAL2P], rffi.INT) + + def os_utime_platform(path, actime, modtime): + import math + l_times = lltype.malloc(TIMEVAL2P.TO, flavor='raw') + fracpart, intpart = math.modf(actime) + l_times[0].c_tv_sec = int(intpart) + l_times[0].c_tv_usec = int(fracpart * 1E6) + fracpart, intpart = math.modf(modtime) + l_times[1].c_tv_sec = int(intpart) + l_times[1].c_tv_usec = int(fracpart * 1E6) + error = os_utimes(path, l_times) + lltype.free(l_times, flavor='raw') + return error + else: + # we only have utime(), which does not allow sub-second resolution + def os_utime_platform(path, actime, modtime): + l_utimbuf = lltype.malloc(UTIMBUFP.TO, flavor='raw') + l_utimbuf.c_actime = int(actime) + l_utimbuf.c_modtime = int(modtime) + error = os_utime(path, l_utimbuf) + lltype.free(l_utimbuf, flavor='raw') + return error def os_utime_llimpl(path, tp): - # XXX right now they're all ints, might change in future - # XXX does not use utimes, even when available # NB. this function is specialized; we get one version where # tp is known to be None, and one version where it is known # to be a tuple of 2 floats. if tp is None: - l_utimebuf = lltype.nullptr(UTIMEBUFP.TO) + error = os_utime(path, lltype.nullptr(UTIMBUFP.TO)) else: - l_utimebuf = lltype.malloc(UTIMEBUFP.TO, flavor='raw') actime, modtime = tp - l_utimebuf.c_actime = int(actime) - l_utimebuf.c_modtime = int(modtime) - error = os_utime(path, l_utimebuf) - if tp is not None: - lltype.free(l_utimebuf, flavor='raw') + error = os_utime_platform(path, actime, modtime) if error == -1: raise OSError(rffi.get_errno(), "os_utime failed") os_utime_llimpl._annspecialcase_ = 'specialize:argtype(1)' Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py Mon Sep 3 17:02:35 2007 @@ -902,7 +902,6 @@ assert open(filename).read() == "2" def test_utime(): - # XXX utimes & float support path = str(udir.ensure("test_utime.txt")) from time import time, sleep t0 = time() From arigo at codespeak.net Mon Sep 3 17:07:15 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 17:07:15 +0200 (CEST) Subject: [pypy-svn] r46281 - pypy/branch/pypy-more-rtti-inprogress/rpython/module Message-ID: <20070903150715.BE48A8168@code0.codespeak.net> Author: arigo Date: Mon Sep 3 17:07:15 2007 New Revision: 46281 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py Log: Fix os.utime() for Linux. 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 Mon Sep 3 17:07:15 2007 @@ -57,7 +57,6 @@ SEEK_CUR = platform.DefinedConstantInteger('SEEK_CUR') SEEK_END = platform.DefinedConstantInteger('SEEK_END') - HAVE_UTIMES = platform.Has('utimes') UTIMBUF = platform.Struct('struct '+underscore_on_windows+'utimbuf', [('actime', rffi.INT), ('modtime', rffi.INT)]) @@ -145,14 +144,22 @@ UTIMBUFP = lltype.Ptr(self.UTIMBUF) os_utime = self.llexternal('utime', [rffi.CCHARP, UTIMBUFP], rffi.INT) - if self.HAVE_UTIMES: + class CConfig: + _includes_ = ['sys/time.h'] + HAVE_UTIMES = platform.Has('utimes') + config = platform.configure(CConfig) + + if config['HAVE_UTIMES']: class CConfig: + _includes_ = ['sys/time.h'] TIMEVAL = platform.Struct('struct timeval', [('tv_sec', rffi.LONG), ('tv_usec', rffi.LONG)]) config = platform.configure(CConfig) TIMEVAL = config['TIMEVAL'] TIMEVAL2P = lltype.Ptr(lltype.FixedSizeArray(TIMEVAL, 2)) - os_utimes = self.llexternal('utimes', [rffi.CCHARP, TIMEVAL2P], rffi.INT) + os_utimes = self.llexternal('utimes', [rffi.CCHARP, TIMEVAL2P], + rffi.INT, + includes=['sys/time.h']) def os_utime_platform(path, actime, modtime): import math From antocuni at codespeak.net Mon Sep 3 17:14:12 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 17:14:12 +0200 (CEST) Subject: [pypy-svn] r46282 - in pypy/dist/pypy/translator/jvm: . test Message-ID: <20070903151412.78A9B8168@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 17:14:11 2007 New Revision: 46282 Modified: pypy/dist/pypy/translator/jvm/generator.py pypy/dist/pypy/translator/jvm/test/test_dict.py Log: bugfix && test passes Modified: pypy/dist/pypy/translator/jvm/generator.py ============================================================================== --- pypy/dist/pypy/translator/jvm/generator.py (original) +++ pypy/dist/pypy/translator/jvm/generator.py Mon Sep 3 17:14:11 2007 @@ -712,6 +712,8 @@ """ Loads from jvm slot #varidx, which is expected to hold a value of type vartype """ assert varidx < self.curfunc.next_offset + if jvartype is jVoid: + return opc = LOAD.for_type(jvartype) self.add_comment(" load_jvm_jar: jvartype=%s varidx=%s" % ( repr(jvartype), repr(varidx))) Modified: pypy/dist/pypy/translator/jvm/test/test_dict.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_dict.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_dict.py Mon Sep 3 17:14:11 2007 @@ -10,8 +10,7 @@ py.test.skip("JVM doesn't support recursive dicts") class TestJvmEmptyDict(JvmTest, oodict.BaseTestEmptyDict): - def test_iterate_over_empty_dict(self): - py.test.skip("Iteration over empty dict is not supported, yet") + pass class TestJvmConstantDict(JvmTest, oodict.BaseTestConstantDict): pass From antocuni at codespeak.net Mon Sep 3 17:21:48 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 17:21:48 +0200 (CEST) Subject: [pypy-svn] r46283 - pypy/dist/pypy/translator/jvm/test Message-ID: <20070903152148.E1E32816F@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 17:21:48 2007 New Revision: 46283 Modified: pypy/dist/pypy/translator/jvm/test/test_string.py Log: horray, these tests pass for free! :-) Modified: pypy/dist/pypy/translator/jvm/test/test_string.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_string.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_string.py Mon Sep 3 17:21:48 2007 @@ -14,16 +14,10 @@ test_char_unichar_eq = test_unichar_const test_char_unichar_eq_2 = test_unichar_const - def test_convert_char_to_unichar(self): - py.test.skip("Fails with arguments, Expected to find an object/array on the stack") - def test_upper(self): py.test.skip("eval has trouble with evaluation of null literals") test_lower = test_upper - def test_float(self): - py.test.skip("JVM does not yet support ooparse_float") - def test_getitem_exc(self): # This test is supposed to crash in a system specific way; # in our case an StringIndexOutOfBounds exception is thrown, From arigo at codespeak.net Mon Sep 3 17:21:57 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 17:21:57 +0200 (CEST) Subject: [pypy-svn] r46284 - pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem Message-ID: <20070903152157.ED2B08177@code0.codespeak.net> Author: arigo Date: Mon Sep 3 17:21:57 2007 New Revision: 46284 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/rffi.py Log: Temporary workaround for an annotation bug. Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/rffi.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/rffi.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/rffi.py Mon Sep 3 17:21:57 2007 @@ -54,6 +54,10 @@ unrolling_arg_tps = unrolling_iterable(enumerate(args)) def wrapper(*args): + # XXX the next line is a workaround for the annotation bug + # shown in rpython.test.test_llann:test_pbctype. Remove it + # when the test is fixed... + assert isinstance(lltype.Signed, lltype.Number) real_args = () if stringpolicy == 'fullauto': to_free = () From antocuni at codespeak.net Mon Sep 3 17:38:59 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 17:38:59 +0200 (CEST) Subject: [pypy-svn] r46285 - in pypy/dist/pypy/translator: cli/test jvm/test oosupport/test_template Message-ID: <20070903153859.D70C68172@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 17:38:59 2007 New Revision: 46285 Added: pypy/dist/pypy/translator/oosupport/test_template/class_.py (contents, props changed) Modified: pypy/dist/pypy/translator/cli/test/test_class.py pypy/dist/pypy/translator/jvm/test/test_class.py Log: move some tests shared by cli and jvm to oosupport. More jvm tests pass. Modified: pypy/dist/pypy/translator/cli/test/test_class.py ============================================================================== --- pypy/dist/pypy/translator/cli/test/test_class.py (original) +++ pypy/dist/pypy/translator/cli/test/test_class.py Mon Sep 3 17:38:59 2007 @@ -1,69 +1,9 @@ import py from pypy.translator.cli.test.runtest import CliTest -from pypy.rpython.test.test_rclass import BaseTestRclass -from pypy.rpython.test.test_rspecialcase import BaseTestRspecialcase +from pypy.translator.oosupport.test_template.class_ import BaseTestClass, BaseTestSpecialcase -class TestCliClass(CliTest, BaseTestRclass): - def test_abstract_method(self): - class Base: - pass - class A(Base): - def f(self, x): - return x+1 - class B(Base): - def f(self, x): - return x+2 - def call(obj, x): - return obj.f(x) - def fn(x): - a = A() - b = B() - return call(a, x) + call(b, x) - assert self.interpret(fn, [0]) == 3 - - def test_abstract_method2(self): - class Root: - pass - class Class1(Root): - pass - class Derived(Class1): - x = 1 - class Class2(Root): - x = 2 - def get_x(obj): - return obj.x - def fn(): - a = Derived() - b = Class2() - return get_x(a) + get_x(b) - assert self.interpret(fn, []) == 3 - - def test_same_name(self): - class A: - def __init__(self, x): - self.x = x - B=A - class A: - def __init__(self, y): - self.y = y - assert A is not B - assert A.__name__ == B.__name__ - def fn(x, y): - obj1 = B(x) - obj2 = A(y) - return obj1.x + obj2.y - assert self.interpret(fn, [1, 2]) == 3 - - def test_ctr_location(self): - class A: - _annspecialcase_ = "specialize:ctr_location" - def __init__(self, x): - self.x = x - def fn(x, y): - a = A(x) - b = A(y) - return a.x + b.x - assert self.interpret(fn, [1, 2]) == 3 +class TestCliClass(CliTest, BaseTestClass): + pass -class TestCliSpecialCase(CliTest, BaseTestRspecialcase): +class TestCliSpecialCase(CliTest, BaseTestSpecialcase): pass Modified: pypy/dist/pypy/translator/jvm/test/test_class.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_class.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_class.py Mon Sep 3 17:38:59 2007 @@ -1,52 +1,10 @@ import py from pypy.translator.jvm.test.runtest import JvmTest -from pypy.rpython.test.test_rclass import BaseTestRclass -from pypy.rpython.test.test_rspecialcase import BaseTestRspecialcase +from pypy.translator.oosupport.test_template.class_ import BaseTestClass, BaseTestSpecialcase -class TestJvmClass(JvmTest, BaseTestRclass): +class TestJvmClass(JvmTest, BaseTestClass): def test_overridden_classattr_as_defaults(self): py.test.skip("JVM doesn't support overridden default value yet") - def test_abstract_method(self): - class Base(object): - pass - class A(Base): - def f(self, x): - return x+1 - class B(Base): - def f(self, x): - return x+2 - def call(obj, x): - return obj.f(x) - def fn(x): - a = A() - b = B() - return call(a, x) + call(b, x) - assert self.interpret(fn, [0]) == 3 - - def test_abstract_method2(self): - class Root(object): - pass - class Class1(Root): - pass - class Derived(Class1): - x = 1 - class Class2(Root): - x = 2 - def get_x(obj): - return obj.x - def fn(): - derived = Derived() - cls2 = Class2() - return get_x(derived) + get_x(cls2) - assert self.interpret(fn, []) == 3 - - def test_same_name(self): - py.test.skip("JVM doesn't support classes with the same name") - - def test_ctr_location(self): - py.test.skip("Ask cuni if this applies to JVM -I don't think so") - - -#class TestCliSpecialCase(CliTest, BaseTestRspecialcase): -# pass +class TestJvmSpecialCase(JvmTest, BaseTestSpecialcase): + pass Added: pypy/dist/pypy/translator/oosupport/test_template/class_.py ============================================================================== --- (empty file) +++ pypy/dist/pypy/translator/oosupport/test_template/class_.py Mon Sep 3 17:38:59 2007 @@ -0,0 +1,68 @@ +import py +from pypy.rpython.test.test_rclass import BaseTestRclass +from pypy.rpython.test.test_rspecialcase import BaseTestRspecialcase + +class BaseTestClass(BaseTestRclass): + def test_abstract_method(self): + class Base: + pass + class A(Base): + def f(self, x): + return x+1 + class B(Base): + def f(self, x): + return x+2 + def call(obj, x): + return obj.f(x) + def fn(x): + a = A() + b = B() + return call(a, x) + call(b, x) + assert self.interpret(fn, [0]) == 3 + + def test_abstract_method2(self): + class Root: + pass + class Class1(Root): + pass + class Derived(Class1): + x = 1 + class Class2(Root): + x = 2 + def get_x(obj): + return obj.x + def fn(): + a = Derived() + b = Class2() + return get_x(a) + get_x(b) + assert self.interpret(fn, []) == 3 + + def test_same_name(self): + class A: + def __init__(self, x): + self.x = x + B=A + class A: + def __init__(self, y): + self.y = y + assert A is not B + assert A.__name__ == B.__name__ + def fn(x, y): + obj1 = B(x) + obj2 = A(y) + return obj1.x + obj2.y + assert self.interpret(fn, [1, 2]) == 3 + + def test_ctr_location(self): + class A: + _annspecialcase_ = "specialize:ctr_location" + def __init__(self, x): + self.x = x + def fn(x, y): + a = A(x) + b = A(y) + return a.x + b.x + assert self.interpret(fn, [1, 2]) == 3 + +class BaseTestSpecialcase(BaseTestRspecialcase): + pass From arigo at codespeak.net Mon Sep 3 17:55:31 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 17:55:31 +0200 (CEST) Subject: [pypy-svn] r46286 - pypy/branch/pypy-more-rtti-inprogress/rpython/module Message-ID: <20070903155531.B0BC8816F@code0.codespeak.net> Author: arigo Date: Mon Sep 3 17:55:29 2007 New Revision: 46286 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py Log: Fix os.listdir() on Linux 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 Mon Sep 3 17:55:29 2007 @@ -620,16 +620,20 @@ else: class CConfig: - DIRENT = platform.Struct('dirent', + _includes_ = ['sys/types.h', 'dirent.h'] + DIRENT = platform.Struct('struct dirent', [('d_name', lltype.FixedSizeArray(rffi.CHAR, 1))]) config = platform.configure(CConfig) DIRENT = config['DIRENT'] DIRENTP = lltype.Ptr(DIRENT) DIRP = rffi.COpaquePtr('DIR') - os_opendir = self.llexternal('opendir', [rffi.CCHARP], DIRP) - os_readdir = self.llexternal('readdir', [DIRP], DIRENTP) - os_closedir = self.llexternal('closedir', [DIRP], rffi.INT) + os_opendir = self.llexternal('opendir', [rffi.CCHARP], DIRP, + includes=CConfig._includes_) + os_readdir = self.llexternal('readdir', [DIRP], DIRENTP, + includes=CConfig._includes_) + os_closedir = self.llexternal('closedir', [DIRP], rffi.INT, + includes=CConfig._includes_) def os_listdir_llimpl(path): dirp = os_opendir(path) From mwh at codespeak.net Mon Sep 3 18:05:24 2007 From: mwh at codespeak.net (mwh at codespeak.net) Date: Mon, 3 Sep 2007 18:05:24 +0200 (CEST) Subject: [pypy-svn] r46287 - pypy/branch/pypy-more-rtti-inprogress/rpython/module Message-ID: <20070903160524.6BA248177@code0.codespeak.net> Author: mwh Date: Mon Sep 3 18:05:23 2007 New Revision: 46287 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py Log: os.name is not a good way of distinguishing os x... Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py Mon Sep 3 18:05:23 2007 @@ -1,4 +1,4 @@ -import os +import os, sys from pypy.annotation import model as annmodel from pypy.rpython.controllerentry import Controller from pypy.rpython.extfunc import register_external @@ -127,7 +127,7 @@ # ____________________________________________________________ # Access to the 'environ' external variable -if os.name.startswith('darwin'): +if sys.platform.startswith('darwin'): CCHARPPP = lltype.Ptr(lltype.FixedSizeArray(rffi.CCHARPP, 1)) _os_NSGetEnviron = rffi.llexternal('_NSGetEnviron', [], CCHARPPP, includes=['crt_externs.h']) From arigo at codespeak.net Mon Sep 3 18:26:46 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 18:26:46 +0200 (CEST) Subject: [pypy-svn] r46288 - pypy/branch/pypy-more-rtti-inprogress/rpython/module Message-ID: <20070903162646.F24F08174@code0.codespeak.net> Author: arigo Date: Mon Sep 3 18:26:46 2007 New Revision: 46288 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py Log: Attempted fix for OS/X Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os_environ.py Mon Sep 3 18:26:46 2007 @@ -104,11 +104,15 @@ if hasattr(__import__(os.name), 'unsetenv'): - os_unsetenv = rffi.llexternal('unsetenv', [rffi.CCHARP], rffi.INT) + if sys.platform.startswith('darwin'): + RETTYPE = lltype.Void + else: + RETTYPE = rffi.INT + os_unsetenv = rffi.llexternal('unsetenv', [rffi.CCHARP], RETTYPE) def unsetenv_llimpl(name): l_name = rffi.str2charp(name) - error = os_unsetenv(l_name) + error = os_unsetenv(l_name) # 'error' is None on OS/X rffi.free_charp(l_name) if error: raise OSError(rffi.get_errno(), "os_unsetenv failed") From arigo at codespeak.net Mon Sep 3 18:26:56 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 18:26:56 +0200 (CEST) Subject: [pypy-svn] r46289 - pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem Message-ID: <20070903162656.408318180@code0.codespeak.net> Author: arigo Date: Mon Sep 3 18:26:55 2007 New Revision: 46289 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py Log: Attempted fix for Windows Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py Mon Sep 3 18:26:55 2007 @@ -418,7 +418,13 @@ # __________ the standard C library __________ if sys.platform == 'win32': - standard_c_lib = ctypes.cdll.LoadLibrary('msvcrt.dll') + # trying to guess the correct libc... only a few tests fail if there + # is a mismatch between the one used by python2x.dll and the one + # loaded here + if sys.version_info < (2, 4): + standard_c_lib = ctypes.cdll.LoadLibrary('msvcrt.dll') + else: + standard_c_lib = ctypes.cdll.LoadLibrary('msvcr71.dll') else: standard_c_lib = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c')) From arigo at codespeak.net Mon Sep 3 18:28:37 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 18:28:37 +0200 (CEST) Subject: [pypy-svn] r46290 - pypy/branch/pypy-more-rtti-inprogress/rpython/module Message-ID: <20070903162837.6AC8C8180@code0.codespeak.net> Author: arigo Date: Mon Sep 3 18:28:37 2007 New Revision: 46290 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py Log: Sprinkling underscores in front of C library function names on Windows, for ctypes to find the functions. 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 Mon Sep 3 18:28:37 2007 @@ -115,7 +115,7 @@ @registering(os.dup) def register_os_dup(self): - os_dup = self.llexternal('dup', [rffi.INT], rffi.INT) + os_dup = self.llexternal(underscore_on_windows+'dup', [rffi.INT], rffi.INT) def dup_llimpl(fd): newfd = rffi.cast(lltype.Signed, os_dup(rffi.cast(rffi.INT, fd))) @@ -128,7 +128,8 @@ @registering(os.dup2) def register_os_dup2(self): - os_dup2 = self.llexternal('dup2', [rffi.INT, rffi.INT], rffi.INT) + os_dup2 = self.llexternal(underscore_on_windows+'dup2', + [rffi.INT, rffi.INT], rffi.INT) def dup2_llimpl(fd, newfd): error = rffi.cast(lltype.Signed, os_dup2(rffi.cast(rffi.INT, fd), @@ -356,7 +357,8 @@ @registering(os.open) def register_os_open(self): - os_open = self.llexternal('open', [rffi.CCHARP, rffi.INT, rffi.MODE_T], + os_open = self.llexternal(underscore_on_windows+'open', + [rffi.CCHARP, rffi.INT, rffi.MODE_T], rffi.INT) def os_open_llimpl(path, flags, mode): @@ -375,7 +377,8 @@ @registering(os.read) def register_os_read(self): - os_read = self.llexternal('read', [rffi.INT, rffi.VOIDP, rffi.SIZE_T], + os_read = self.llexternal(underscore_on_windows+'read', + [rffi.INT, rffi.VOIDP, rffi.SIZE_T], rffi.SIZE_T) def os_read_llimpl(fd, count): @@ -401,8 +404,9 @@ @registering(os.write) def register_os_write(self): - os_write = self.llexternal('write', [rffi.INT, rffi.VOIDP, - rffi.SIZE_T], rffi.SIZE_T) + os_write = self.llexternal(underscore_on_windows+'write', + [rffi.INT, rffi.VOIDP, rffi.SIZE_T], + rffi.SIZE_T) def os_write_llimpl(fd, data): count = len(data) @@ -428,7 +432,7 @@ @registering(os.close) def register_os_close(self): - os_close = self.llexternal('close', [rffi.INT], rffi.INT) + os_close = self.llexternal(underscore_on_windows+'close', [rffi.INT], rffi.INT) def close_llimpl(fd): error = rffi.cast(lltype.Signed, os_close(rffi.cast(rffi.INT, fd))) @@ -781,7 +785,7 @@ @registering(os.isatty) def register_os_isatty(self): - os_isatty = self.llexternal('isatty', [rffi.INT], rffi.INT) + os_isatty = self.llexternal(underscore_on_windows+'isatty', [rffi.INT], rffi.INT) def isatty_llimpl(fd): res = os_isatty(rffi.cast(rffi.INT, fd)) @@ -816,7 +820,7 @@ @registering(os.unlink) def register_os_unlink(self): - os_unlink = self.llexternal('unlink', [rffi.CCHARP], rffi.INT) + os_unlink = self.llexternal(underscore_on_windows+'unlink', [rffi.CCHARP], rffi.INT) def unlink_llimpl(pathname): res = os_unlink(pathname) @@ -828,7 +832,7 @@ @registering(os.chdir) def register_os_chdir(self): - os_chdir = self.llexternal('chdir', [rffi.CCHARP], rffi.INT) + os_chdir = self.llexternal(underscore_on_windows+'chdir', [rffi.CCHARP], rffi.INT) def chdir_llimpl(path): res = os_chdir(path) @@ -844,7 +848,8 @@ ARG2 = [] # no 'mode' argument on Windows - just ignored else: ARG2 = [rffi.MODE_T] - os_mkdir = self.llexternal('mkdir', [rffi.CCHARP]+ARG2, rffi.INT) + os_mkdir = self.llexternal(underscore_on_windows+'mkdir', + [rffi.CCHARP]+ARG2, rffi.INT) IGNORE_MODE = len(ARG2) == 0 def mkdir_llimpl(pathname, mode): @@ -860,7 +865,7 @@ @registering(os.rmdir) def register_os_rmdir(self): - os_rmdir = self.llexternal('rmdir', [rffi.CCHARP], rffi.INT) + os_rmdir = self.llexternal(underscore_on_windows+'rmdir', [rffi.CCHARP], rffi.INT) def rmdir_llimpl(pathname): res = os_rmdir(pathname) @@ -872,7 +877,7 @@ @registering(os.chmod) def register_os_chmod(self): - os_chmod = self.llexternal('chmod', [rffi.CCHARP, rffi.MODE_T], + os_chmod = self.llexternal(underscore_on_windows+'chmod', [rffi.CCHARP, rffi.MODE_T], rffi.INT) def chmod_llimpl(path, mode): @@ -898,7 +903,7 @@ @registering(os.umask) def register_os_umask(self): - os_umask = self.llexternal('umask', [rffi.MODE_T], rffi.MODE_T) + os_umask = self.llexternal(underscore_on_windows+'umask', [rffi.MODE_T], rffi.MODE_T) def umask_llimpl(fd): res = os_umask(rffi.cast(rffi.MODE_T, fd)) From arigo at codespeak.net Mon Sep 3 18:32:31 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 3 Sep 2007 18:32:31 +0200 (CEST) Subject: [pypy-svn] r46291 - pypy/branch/pypy-more-rtti-inprogress/rpython/module/test Message-ID: <20070903163231.151618180@code0.codespeak.net> Author: arigo Date: Mon Sep 3 18:32:30 2007 New Revision: 46291 Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/test/test_posix.py Log: Fix tests. Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/test/test_posix.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/rpython/module/test/test_posix.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/test/test_posix.py Mon Sep 3 18:32:30 2007 @@ -104,20 +104,19 @@ res = self.interpret(f,[fi]) raises( OSError, os.fstat, fi) - def test_ftruncate(self): - def f(fi,len): - posix.ftruncate(fi,len) - fi = os.open(path,os.O_RDWR,0777) - func = self.interpret(f,[fi,6]) - assert os.fstat(fi).st_size == 6 - - def test_getuid(self): - def f(): - return os.getuid() - assert self.interpret(f, []) == f() - -if not hasattr(os, 'ftruncate'): - del BaseTestPosix.test_ftruncate + if hasattr(os, 'ftruncate'): + def test_ftruncate(self): + def f(fi,len): + os.ftruncate(fi,len) + fi = os.open(path,os.O_RDWR,0777) + func = self.interpret(f,[fi,6]) + assert os.fstat(fi).st_size == 6 + + if hasattr(os, 'getuid'): + def test_getuid(self): + def f(): + return os.getuid() + assert self.interpret(f, []) == f() class TestLLtype(BaseTestPosix, LLRtypeMixin): if False and hasattr(os, 'uname'): From antocuni at codespeak.net Mon Sep 3 22:24:38 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 22:24:38 +0200 (CEST) Subject: [pypy-svn] r46294 - in pypy/dist/pypy/translator: cli jvm oosupport Message-ID: <20070903202438.484B98146@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 22:24:36 2007 New Revision: 46294 Modified: pypy/dist/pypy/translator/cli/ilgenerator.py pypy/dist/pypy/translator/cli/metavm.py pypy/dist/pypy/translator/jvm/generator.py pypy/dist/pypy/translator/oosupport/metavm.py Log: refactor metavm._Call: now most of the logic is shared between jvm and cli Modified: pypy/dist/pypy/translator/cli/ilgenerator.py ============================================================================== --- pypy/dist/pypy/translator/cli/ilgenerator.py (original) +++ pypy/dist/pypy/translator/cli/ilgenerator.py Mon Sep 3 22:24:36 2007 @@ -308,6 +308,10 @@ def emit(self, instr, *args): self.ilasm.opcode(instr, *args) + def call_primitive(self, op, module, name): + func_name = '[pypylib]pypy.builtin.%s::%s' % (module, name) + self.call_op(op, func_name) + def call_graph(self, graph, func_name=None): if func_name is None: # else it is a suggested primitive self.db.pending_function(graph) Modified: pypy/dist/pypy/translator/cli/metavm.py ============================================================================== --- pypy/dist/pypy/translator/cli/metavm.py (original) +++ pypy/dist/pypy/translator/cli/metavm.py Mon Sep 3 22:24:36 2007 @@ -2,36 +2,21 @@ from pypy.rpython.ootypesystem import ootype from pypy.translator.oosupport.metavm import Generator, InstructionList, MicroInstruction,\ PushAllArgs, StoreResult, GetField, SetField, DownCast +from pypy.translator.oosupport.metavm import _Call as _OOCall from pypy.translator.cli.comparer import EqualityComparer from pypy.translator.cli.cts import WEAKREF from pypy.translator.cli.dotnet import _static_meth, NativeInstance STRING_HELPER_CLASS = '[pypylib]pypy.runtime.String' -class _Call(MicroInstruction): +class _Call(_OOCall): + def render(self, generator, op): callee = op.args[0].value if isinstance(callee, _static_meth): self._render_native_function(generator, callee, op.args) - elif hasattr(callee, "graph"): - graph = callee.graph - method_name = oopspec.get_method_name(graph, op) - if method_name is None: - self._render_function(generator, graph, op.args) - else: - self._render_method(generator, method_name, op.args[1:]) else: - self._render_primitive_function(generator, callee, op) - - - def _load_arg_or_null(self, generator, arg): - if arg.concretetype is ootype.Void: - if arg.value is None: - generator.ilasm.opcode('ldnull') # special-case: use None as a null value - else: - assert False, "Don't know how to load this arg" - else: - generator.load(arg) + _OOCall.render(self, generator, op) def _render_native_function(self, generator, funcdesc, args): for func_arg in args[1:]: # push parameters @@ -45,17 +30,20 @@ signature = '%s %s::%s(%s)' % (ret_type, funcdesc._cls._name, funcdesc._name, arg_list) generator.call_signature(signature) - def _render_function(self, generator, graph, args): - primitive = getattr(graph.func, 'suggested_primitive', False) - for func_arg in args[1:]: # push parameters - generator.load(func_arg) - - if primitive: - _, module = graph.func.__module__.rsplit('.', 1) - func_name = '[pypylib]pypy.builtin.%s::%s' % (module, graph.func.func_name) - generator.call_graph(graph, func_name) + def _load_arg_or_null(self, generator, arg): + if arg.concretetype is ootype.Void: + if arg.value is None: + generator.ilasm.opcode('ldnull') # special-case: use None as a null value + else: + assert False, "Don't know how to load this arg" else: - generator.call_graph(graph) + generator.load(arg) + + +class _CallMethod(_Call): + def render(self, generator, op): + method = op.args[0] + self._render_method(generator, method.value, op.args[1:]) def _render_method(self, generator, method_name, args): this = args[0] @@ -95,20 +83,8 @@ method_name == 'll_current_key')): generator.ilasm.pop() - def _render_primitive_function(self, generator, callee, op): - for func_arg in op.args[1:]: # push parameters - self._load_arg_or_null(generator, func_arg) - module, name = callee._name.split(".") - func_name = '[pypylib]pypy.builtin.%s::%s' % (module, name) - generator.call_op(op, func_name) - -class _CallMethod(_Call): - def render(self, generator, op): - method = op.args[0] - self._render_method(generator, method.value, op.args[1:]) - -class _IndirectCall(_Call): +class _IndirectCall(_CallMethod): def render(self, generator, op): # discard the last argument because it's used only for analysis self._render_method(generator, 'Invoke', op.args[:-1]) Modified: pypy/dist/pypy/translator/jvm/generator.py ============================================================================== --- pypy/dist/pypy/translator/jvm/generator.py (original) +++ pypy/dist/pypy/translator/jvm/generator.py Mon Sep 3 22:24:36 2007 @@ -1014,7 +1014,8 @@ # we have to "deal with it" self.prepare_generic_result(RETTYPE) - def call_primitive(self, graph): + def call_primitive(self, op, module, name): + graph = op.args[0].value # XXX argtypes, rettype = self.db.types_for_graph(graph) mthd = Method.s(jPyPy, graph.func.func_name, argtypes, rettype) self.emit(mthd) Modified: pypy/dist/pypy/translator/oosupport/metavm.py ============================================================================== --- pypy/dist/pypy/translator/oosupport/metavm.py (original) +++ pypy/dist/pypy/translator/oosupport/metavm.py Mon Sep 3 22:24:36 2007 @@ -172,7 +172,7 @@ Stack: argN, arg2, arg1, this, ... -> ret, ... """ raise NotImplementedError - def call_primitive(self, graph): + def call_primitive(self, op, module, name): """ Like call_graph, but it has been suggested that the method be rendered as a primitive. @@ -395,23 +395,34 @@ def render(self, generator, op): generator.branch_conditionally(False, self.label) + class _Call(MicroInstruction): + + def _get_primitive_name(self, callee): + try: + graph = callee.graph + except AttributeError: + return callee._name.rsplit('.', 1) + else: + if getattr(graph.func, 'suggested_primitive', False): + _, module = graph.func.__module__.rsplit('.', 1) + return module, graph.func.func_name + else: + return None + def render(self, generator, op): callee = op.args[0].value - graph = callee.graph - method_name = None # XXX oopspec.get_method_name(graph, op) + is_primitive = self._get_primitive_name(callee) for arg in op.args[1:]: generator.load(arg) - if method_name is None: - if getattr(graph.func, 'suggested_primitive', False): - generator.call_primitive(graph) - else: - generator.call_graph(graph) + if is_primitive: + module, name = is_primitive + generator.call_primitive(op, module, name) else: - this = op.args[1] - generator.call_method(this.concretetype, method_name) + generator.call_graph(callee.graph) + class _CallMethod(MicroInstruction): def render(self, generator, op): From antocuni at codespeak.net Mon Sep 3 22:37:28 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 3 Sep 2007 22:37:28 +0200 (CEST) Subject: [pypy-svn] r46295 - in pypy/dist/pypy/translator/jvm: . src/pypy test Message-ID: <20070903203728.A51F58149@code0.codespeak.net> Author: antocuni Date: Mon Sep 3 22:37:28 2007 New Revision: 46295 Modified: pypy/dist/pypy/translator/jvm/database.py pypy/dist/pypy/translator/jvm/generator.py pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java pypy/dist/pypy/translator/jvm/test/test_builtin.py Log: correctly implement generator.call_primitive. Implement ll_math.{fmod,floor}. Modified: pypy/dist/pypy/translator/jvm/database.py ============================================================================== --- pypy/dist/pypy/translator/jvm/database.py (original) +++ pypy/dist/pypy/translator/jvm/database.py Mon Sep 3 22:37:28 2007 @@ -119,12 +119,15 @@ then the return would be: ( (jString, jString), jBool ) """ - argtypes = [arg.concretetype for arg in graph.getargs() - if arg.concretetype is not ootype.Void] - jargtypes = tuple([self.lltype_to_cts(argty) for argty in argtypes]) - rettype = graph.getreturnvar().concretetype - jrettype = self.lltype_to_cts(rettype) - return jargtypes, jrettype + ARGS = [v.concretetype for v in graph.getargs()] + RESULT = graph.getreturnvar().concretetype + return self.types_for_signature(ARGS, RESULT) + + def types_for_signature(self, ARGS, RESULT): + ARGS = [ARG for ARG in ARGS if ARG is not ootype.Void] + jargtypes = tuple([self.lltype_to_cts(ARG) for ARG in ARGS]) + jrettype = self.lltype_to_cts(RESULT) + return jargtypes, jrettype def _function_for_graph(self, classobj, funcnm, is_static, graph): Modified: pypy/dist/pypy/translator/jvm/generator.py ============================================================================== --- pypy/dist/pypy/translator/jvm/generator.py (original) +++ pypy/dist/pypy/translator/jvm/generator.py Mon Sep 3 22:37:28 2007 @@ -1015,9 +1015,9 @@ self.prepare_generic_result(RETTYPE) def call_primitive(self, op, module, name): - graph = op.args[0].value # XXX - argtypes, rettype = self.db.types_for_graph(graph) - mthd = Method.s(jPyPy, graph.func.func_name, argtypes, rettype) + callee = op.args[0].value + argtypes, rettype = self.db.types_for_signature(callee._TYPE.ARGS, callee._TYPE.RESULT) + mthd = Method.s(jPyPy, name, argtypes, rettype) self.emit(mthd) def call_oostring(self, OOTYPE): Modified: pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java ============================================================================== --- pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java (original) +++ pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java Mon Sep 3 22:37:28 2007 @@ -884,6 +884,19 @@ } // ---------------------------------------------------------------------- + // ll_math + + public static double ll_math_floor(double x) + { + return Math.floor(x); + } + + public static double ll_math_fmod(double x, double y) + { + return x % y; + } + + // ---------------------------------------------------------------------- // Convenient Helpers for throwing exceptions // // Also, an abstraction barrier: at a later date we may want to Modified: pypy/dist/pypy/translator/jvm/test/test_builtin.py ============================================================================== --- pypy/dist/pypy/translator/jvm/test/test_builtin.py (original) +++ pypy/dist/pypy/translator/jvm/test/test_builtin.py Mon Sep 3 22:37:28 2007 @@ -27,13 +27,7 @@ def test_os_isdir(self): py.test.skip("ll_os_stat is not currently implemented in the Jvm backed") - - def test_builtin_math_floor(self): - py.test.skip("metavm.py needs to be updated to handle this math op; graphless extrernal") - - def test_builtin_math_fmod(self): - py.test.skip("metavm.py needs to be updated to handle this math op; graphless extrernal") - + def test_builtin_math_frexp(self): py.test.skip("metavm.py needs to be updated to handle this math op; graphless extrernal") From pypy-svn at codespeak.net Tue Sep 4 06:33:27 2007 From: pypy-svn at codespeak.net (Loretta Mcgowan) Date: Tue, 35 Aug 2007 05:33:27 +0100 Subject: [pypy-svn] Pharmacy Shop Message-ID: <483541716.04632409696056@codespeak.net> New pharmacy shop: http://selfoccur.com From arigo at codespeak.net Tue Sep 4 12:47:39 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 4 Sep 2007 12:47:39 +0200 (CEST) Subject: [pypy-svn] r46300 - pypy/branch/pypy-more-rtti-inprogress/module/posix/test Message-ID: <20070904104739.24C34817D@code0.codespeak.net> Author: arigo Date: Tue Sep 4 12:47:37 2007 New Revision: 46300 Modified: pypy/branch/pypy-more-rtti-inprogress/module/posix/test/test_posix2.py Log: Skip tests for Windows. Modified: pypy/branch/pypy-more-rtti-inprogress/module/posix/test/test_posix2.py ============================================================================== --- pypy/branch/pypy-more-rtti-inprogress/module/posix/test/test_posix2.py (original) +++ pypy/branch/pypy-more-rtti-inprogress/module/posix/test/test_posix2.py Tue Sep 4 12:47:37 2007 @@ -26,8 +26,9 @@ cls.w_path = space.wrap(str(path)) cls.w_path2 = space.wrap(str(path2)) cls.w_pdir = space.wrap(str(pdir)) - cls.w_getuid = space.wrap(os.getuid()) - cls.w_geteuid = space.wrap(os.geteuid()) + if hasattr(os, 'getuid'): + cls.w_getuid = space.wrap(os.getuid()) + cls.w_geteuid = space.wrap(os.geteuid()) def test_posix_is_pypy_s(self): assert self.posix.__file__ @@ -268,10 +269,11 @@ assert isinstance(i, str) assert isinstance(res, tuple) - def test_os_getuid(self): - os = self.posix - assert os.getuid() == self.getuid - assert os.geteuid() == self.geteuid + if hasattr(os, 'getuid'): + def test_os_getuid(self): + os = self.posix + assert os.getuid() ==