[pypy-svn] r25675 - in pypy/dist/pypy/rpython/rctypes: . test
arigo at codespeak.net
arigo at codespeak.net
Mon Apr 10 20:05:56 CEST 2006
Author: arigo
Date: Mon Apr 10 20:05:55 2006
New Revision: 25675
Modified:
pypy/dist/pypy/rpython/rctypes/rpointer.py
pypy/dist/pypy/rpython/rctypes/test/test_rarray.py
Log:
Clean-ups of old commented-out code, and commenting out some tests.
Modified: pypy/dist/pypy/rpython/rctypes/rpointer.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rpointer.py (original)
+++ pypy/dist/pypy/rpython/rctypes/rpointer.py Mon Apr 10 20:05:55 2006
@@ -88,81 +88,7 @@
# copy the whole structure's content over
reccopy(hop.llops, v_new_c_data, v_target)
-#def registerPointerType(ptrtype):
-# """Adds a new pointer type to the extregistry.
-#
-# Since pointers can be created to primitive ctypes objects, arrays,
-# structs and structs are not predefined each new pointer type is
-# registered in the extregistry as it is identified.
-#
-# The new pointers that are created have a "contents" attribute
-# which, when retrieved, in effect dereferences the pointer and
-# returns the referenced value.
-# """
-# def compute_result_annotation(s_self, s_arg):
-# return annmodel.SomeCTypesObject(ptrtype,
-# annmodel.SomeCTypesObject.OWNSMEMORY)
-#
-# def specialize_call(hop):
-# raise RuntimeError('foo')
-#
-# contentsType = annmodel.SomeCTypesObject(ptrtype._type_,
-# annmodel.SomeCTypesObject.MEMORYALIAS)
-#
-# def get_repr(rtyper, s_pointer):
-# return PointerRepr(rtyper, s_pointer, contentsType)
-#
-# type_entry = extregistry.register_type(ptrtype,
-# specialize_call=specialize_call,
-# get_repr=get_repr)
-# type_entry.get_field_annotation = {'contents': contentsType}.__getitem__
-#
-# return extregistry.register_value(ptrtype,
-# compute_result_annotation=compute_result_annotation,
-# specialize_call=specialize_call)
-#
-#def pointer_compute_annotation(metatype, the_type):
-# """compute the annotation of POINTER() calls to create a ctypes
-# pointer for the given type
-# """
-#
-# def pointer_compute_result_annotation(s_arg):
-# """Called to compute the result annotation of
-# POINTER(<ctypes type>). This happens to return a new
-# class which itself is treated as SomeBuiltin because when
-# called it creates a new pointer.
-#
-# NOTE: To handle a myriad of possible pointer types, each
-# ctypes type that is passed to POINTER() calls is itself
-# registered if it isn't already.
-# """
-# ptrtype = POINTER(s_arg.const)
-#
-# if not extregistry.is_registered_type(ptrtype):
-# entry = registerPointerType(ptrtype)
-# else:
-# entry = extregistry.lookup(ptrtype)
-#
-# s_self = annmodel.SomeCTypesObject(ptrtype,
-# annmodel.SomeCTypesObject.OWNSMEMORY)
-#
-#
-# return annmodel.SomeBuiltin(entry.compute_result_annotation,
-# s_self=s_self,
-# methodname=ptrtype.__name__)
-#
-# # annotation of POINTER (not the call) is SomeBuitin which provides
-# # a way of computing the result annotation of POINTER(<ctypes type>)
-# return annmodel.SomeBuiltin(pointer_compute_result_annotation,
-# methodname=the_type.__name__)
-#
-#def pointer_specialize_call(hop):
-# raise RuntimeError("foo")
-#
-# handles POINTER() calls
-#value_entry = extregistry.register_value(POINTER,
-# compute_annotation=pointer_compute_annotation,
-# specialize_call=pointer_specialize_call)
+# ____________________________________________________________
def pointertype_compute_annotation(metatype, type):
def compute_result_annotation(*arg_s):
Modified: pypy/dist/pypy/rpython/rctypes/test/test_rarray.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rarray.py (original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rarray.py Mon Apr 10 20:05:55 2006
@@ -19,8 +19,6 @@
c_int_10 = ARRAY(c_int,10)
-#py.test.skip("Reworking primitive types")
-
class Test_annotation:
def test_annotate_array(self):
def create_array():
@@ -50,21 +48,21 @@
if conftest.option.view:
t.view()
- def x_test_annotate_array_slice_access(self):
- def slice_access():
- my_array = c_int_10()
- #f#my_array[0:7] = c_int(1) * 7
- my_array[0:5] = range(5)
-
- return my_array[0:5]
-
- t = TranslationContext()
- a = t.buildannotator()
- s = a.build_types(slice_access, [])
- #d#t.view()
- #d#print "v90:", s, type(s)
- assert s.knowntype == list
- s.listdef.listitem.s_value.knowntype == int
+## def test_annotate_array_slice_access(self):
+## def slice_access():
+## my_array = c_int_10()
+## #f#my_array[0:7] = c_int(1) * 7
+## my_array[0:5] = range(5)
+
+## return my_array[0:5]
+
+## t = TranslationContext()
+## a = t.buildannotator()
+## s = a.build_types(slice_access, [])
+## #d#t.view()
+## #d#print "v90:", s, type(s)
+## assert s.knowntype == list
+## s.listdef.listitem.s_value.knowntype == int
def test_annotate_array_access_variable(self):
def access_with_variable():
@@ -82,25 +80,25 @@
assert s.knowntype == int
#t#t.view()
- def test_annotate_array_access_index_error_on_positive_index(self):
- def access_with_invalid_positive_index():
- my_array = c_int_10()
- return my_array[10]
+## def test_annotate_array_access_index_error_on_positive_index(self):
+## def access_with_invalid_positive_index():
+## my_array = c_int_10()
+## return my_array[10]
- t = TranslationContext()
- a = t.buildannotator()
+## t = TranslationContext()
+## a = t.buildannotator()
- py.test.raises(IndexError, "s = a.build_types(access_with_invalid_positive_index,[])")
+## py.test.raises(IndexError, "s = a.build_types(access_with_invalid_positive_index,[])")
- def test_annotate_array_access_index_error_on_negative_index(self):
- def access_with_invalid_negative_index():
- my_array = c_int_10()
- return my_array[-11]
+## def test_annotate_array_access_index_error_on_negative_index(self):
+## def access_with_invalid_negative_index():
+## my_array = c_int_10()
+## return my_array[-11]
- t = TranslationContext()
- a = t.buildannotator()
+## t = TranslationContext()
+## a = t.buildannotator()
- py.test.raises(IndexError, "s = a.build_types(access_with_invalid_negative_index,[])")
+## py.test.raises(IndexError, "s = a.build_types(access_with_invalid_negative_index,[])")
class Test_specialization:
def test_specialize_array(self):
More information about the Pypy-commit
mailing list