[pypy-svn] r29776 - in pypy/dist/pypy: rpython/lltypesystem/module rpython/module rpython/ootypesystem/module rpython/test translator/c
antocuni at codespeak.net
antocuni at codespeak.net
Fri Jul 7 19:40:17 CEST 2006
Author: antocuni
Date: Fri Jul 7 19:40:13 2006
New Revision: 29776
Added:
pypy/dist/pypy/rpython/lltypesystem/module/ll_strtod.py (contents, props changed)
pypy/dist/pypy/rpython/ootypesystem/module/ll_strtod.py (contents, props changed)
Modified:
pypy/dist/pypy/rpython/module/ll_strtod.py
pypy/dist/pypy/rpython/test/test_rarithmetic.py
pypy/dist/pypy/translator/c/extfunc.py
Log:
Make strto2.formatd typesystem-specific and add the corresponding
test.
Hope not to break the translation again :-).
Added: pypy/dist/pypy/rpython/lltypesystem/module/ll_strtod.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/lltypesystem/module/ll_strtod.py Fri Jul 7 19:40:13 2006
@@ -0,0 +1,10 @@
+from pypy.rpython import rarithmetic
+from pypy.rpython.module.support import LLSupport
+from pypy.tool.staticmethods import ClassMethods
+
+class Implementation(object, LLSupport):
+ __metaclass__ = ClassMethods
+
+ def ll_strtod_formatd(cls, fmt, x):
+ return cls.to_rstr(rarithmetic.formatd(cls.from_rstr(fmt), x))
+ ll_strtod_formatd.suggested_primitive = True
Modified: pypy/dist/pypy/rpython/module/ll_strtod.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_strtod.py (original)
+++ pypy/dist/pypy/rpython/module/ll_strtod.py Fri Jul 7 19:40:13 2006
@@ -10,6 +10,3 @@
LLSupport.from_rstr(exponent))
ll_strtod_parts_to_float.suggested_primitive = True
-def ll_strtod_formatd(fmt, x):
- return LLSupport.to_rstr(rarithmetic.formatd(LLSupport.from_rstr(fmt), x))
-ll_strtod_formatd.suggested_primitive = True
Added: pypy/dist/pypy/rpython/ootypesystem/module/ll_strtod.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/ootypesystem/module/ll_strtod.py Fri Jul 7 19:40:13 2006
@@ -0,0 +1,10 @@
+from pypy.rpython import rarithmetic
+from pypy.rpython.module.support import OOSupport
+from pypy.tool.staticmethods import ClassMethods
+
+class Implementation(object, OOSupport):
+ __metaclass__ = ClassMethods
+
+ def ll_strtod_formatd(cls, fmt, x):
+ return cls.to_rstr(rarithmetic.formatd(cls.from_rstr(fmt), x))
+ ll_strtod_formatd.suggested_primitive = True
Modified: pypy/dist/pypy/rpython/test/test_rarithmetic.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rarithmetic.py (original)
+++ pypy/dist/pypy/rpython/test/test_rarithmetic.py Fri Jul 7 19:40:13 2006
@@ -1,3 +1,4 @@
+from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
from pypy.rpython.rarithmetic import *
import sys
import py
@@ -264,3 +265,20 @@
def test_abs():
assert type(abs(r_longlong(1))) is r_longlong
+
+
+class BaseTestRarithmetic(BaseRtypingTest):
+ def test_formatd(self):
+ from pypy.rpython.rarithmetic import formatd
+ def f(x):
+ return formatd('%.2f', x)
+ res = self.ll_to_string(self.interpret(f, [10/3.0]))
+ assert res == '3.33'
+
+
+class TestLLtype(BaseTestRarithmetic, LLRtypeMixin):
+ pass
+
+class TestOOtype(BaseTestRarithmetic, OORtypeMixin):
+ pass
+
Modified: pypy/dist/pypy/translator/c/extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/extfunc.py (original)
+++ pypy/dist/pypy/translator/c/extfunc.py Fri Jul 7 19:40:13 2006
@@ -9,6 +9,7 @@
from pypy.rpython.module import ll_stackless, ll_stack
from pypy.rpython.lltypesystem.module.ll_os import STAT_RESULT, Implementation as impl
from pypy.rpython.lltypesystem.module import ll_math as ll_math2
+from pypy.rpython.lltypesystem.module import ll_strtod as ll_strtod2
from pypy.module.thread.rpython import ll_thread
# table of functions hand-written in src/ll_*.h
@@ -51,7 +52,7 @@
ll_math.ll_math_hypot: 'LL_math_hypot',
ll_strtod.ll_strtod_parts_to_float:
'LL_strtod_parts_to_float',
- ll_strtod.ll_strtod_formatd:
+ ll_strtod2.Implementation.ll_strtod_formatd.im_func:
'LL_strtod_formatd',
ll_thread.ll_newlock: 'LL_thread_newlock',
ll_thread.ll_acquirelock: 'LL_thread_acquirelock',
More information about the Pypy-commit
mailing list