[pypy-commit] pypy numpypy-problems: start to implement StringType.coerce
mattip
noreply at buildbot.pypy.org
Sun Aug 19 22:57:21 CEST 2012
Author: mattip <matti.picus at gmail.com>
Branch: numpypy-problems
Changeset: r56760:5448fac77bb6
Date: 2012-08-19 23:56 +0300
http://bitbucket.org/pypy/pypy/changeset/5448fac77bb6/
Log: start to implement StringType.coerce
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -78,7 +78,7 @@
def __repr__(self):
return self.__class__.__name__
-class Primitive(object):
+class BasePrimitive(object):
_mixin_ = True
def get_element_size(self):
@@ -139,6 +139,8 @@
def pack_str(self, box):
return struct.pack(self.format_code, self.unbox(box))
+
+class Primitive(BasePrimitive):
@simple_binary_op
def add(self, v1, v2):
return v1 + v2
@@ -890,17 +892,16 @@
BoxType = interp_boxes.W_Float64Box
format_code = "d"
-class BaseStringType(object):
- _mixin_ = True
-
+class BaseStringType(BasePrimitive):
def __init__(self, size=0):
self.size = size
- def get_element_size(self):
- return self.size * rffi.sizeof(self.T)
-
class StringType(BaseType, BaseStringType):
T = lltype.Char
+ BoxType = interp_boxes.W_StringBox
+
+ def _coerce(self, space, w_item):
+ return self.box(space.str_w(space.call_function(space.w_str, w_item)))
class VoidType(BaseType, BaseStringType):
T = lltype.Char
More information about the pypy-commit
mailing list